LCOV - code coverage report
Current view: top level - cui/source/tabpages - swpossizetabpage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 820 0.0 %
Date: 2014-11-03 Functions: 0 40 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <cstddef>
      21             : #include <swpossizetabpage.hxx>
      22             : #include <dialmgr.hxx>
      23             : #include <svx/dlgutil.hxx>
      24             : #include <svx/anchorid.hxx>
      25             : #include <svl/aeitem.hxx>
      26             : #include <svx/swframevalidation.hxx>
      27             : #include <cuires.hrc>
      28             : #include <sfx2/htmlmode.hxx>
      29             : #include <svx/svdview.hxx>
      30             : #include <svx/svdpagv.hxx>
      31             : #include <svx/rectenum.hxx>
      32             : #include <sal/macros.h>
      33             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      34             : #include <com/sun/star/text/HoriOrientation.hpp>
      35             : #include <com/sun/star/text/VertOrientation.hpp>
      36             : #include <com/sun/star/text/RelOrientation.hpp>
      37             : #include <svx/dialogs.hrc>
      38             : #include <boost/scoped_ptr.hpp>
      39             : 
      40             : using namespace ::com::sun::star::text;
      41             : #define SwFPos SvxSwFramePosString
      42             : 
      43             : struct FrmMap
      44             : {
      45             :     SvxSwFramePosString::StringId   eStrId;
      46             :     SvxSwFramePosString::StringId   eMirrorStrId;
      47             :     short                           nAlign;
      48             :     sal_uLong                           nLBRelations;
      49             : };
      50             : 
      51             : struct RelationMap
      52             : {
      53             :     SvxSwFramePosString::StringId   eStrId;
      54             :     SvxSwFramePosString::StringId   eMirrorStrId;
      55             :     sal_uLong  nLBRelation;
      56             :     short nRelation;
      57             : };
      58             : struct StringIdPair_Impl
      59             : {
      60             :     SvxSwFramePosString::StringId eHori;
      61             :     SvxSwFramePosString::StringId eVert;
      62             : };
      63             : 
      64             : #define LB_FRAME                0x00000001L // paragraph text area
      65             : #define LB_PRTAREA              0x00000002L // paragraph text area + indents
      66             : #define LB_VERT_FRAME           0x00000004L // vertical paragraph text area
      67             : #define LB_VERT_PRTAREA         0x00000008L // vertical paragraph text area + indents
      68             : #define LB_REL_FRM_LEFT         0x00000010L // left paragraph margin
      69             : #define LB_REL_FRM_RIGHT        0x00000020L // right paragraph margin
      70             : 
      71             : #define LB_REL_PG_LEFT          0x00000040L // left page margin
      72             : #define LB_REL_PG_RIGHT         0x00000080L // right page margin
      73             : #define LB_REL_PG_FRAME         0x00000100L // complete page
      74             : #define LB_REL_PG_PRTAREA       0x00000200L // text area of page
      75             : 
      76             : #define LB_FLY_REL_PG_LEFT      0x00000400L // left frame margin
      77             : #define LB_FLY_REL_PG_RIGHT     0x00000800L // right frame margin
      78             : #define LB_FLY_REL_PG_FRAME     0x00001000L // complete frame
      79             : #define LB_FLY_REL_PG_PRTAREA   0x00002000L // frame interior
      80             : 
      81             : #define LB_REL_BASE             0x00010000L // as char, relative to baseline
      82             : #define LB_REL_CHAR             0x00020000L // as char, relative to character
      83             : #define LB_REL_ROW              0x00040000L // as char, relative to line
      84             : 
      85             : // #i22305#
      86             : #define LB_FLY_VERT_FRAME       0x00100000L // vertical entire frame
      87             : #define LB_FLY_VERT_PRTAREA     0x00200000L // vertical frame text area
      88             : 
      89             : // #i22341#
      90             : #define LB_VERT_LINE            0x00400000L // vertical text line
      91             : 
      92             : static RelationMap aRelationMap[] =
      93             : {
      94             :     {SwFPos::FRAME,         SwFPos::FRAME,             LB_FRAME,           RelOrientation::FRAME},
      95             :     {SwFPos::PRTAREA,       SwFPos::PRTAREA,           LB_PRTAREA,         RelOrientation::PRINT_AREA},
      96             :     {SwFPos::REL_PG_LEFT,   SwFPos::MIR_REL_PG_LEFT,   LB_REL_PG_LEFT,     RelOrientation::PAGE_LEFT},
      97             :     {SwFPos::REL_PG_RIGHT,  SwFPos::MIR_REL_PG_RIGHT,  LB_REL_PG_RIGHT,    RelOrientation::PAGE_RIGHT},
      98             :     {SwFPos::REL_FRM_LEFT,  SwFPos::MIR_REL_FRM_LEFT,  LB_REL_FRM_LEFT,    RelOrientation::FRAME_LEFT},
      99             :     {SwFPos::REL_FRM_RIGHT, SwFPos::MIR_REL_FRM_RIGHT, LB_REL_FRM_RIGHT,   RelOrientation::FRAME_RIGHT},
     100             :     {SwFPos::REL_PG_FRAME,  SwFPos::REL_PG_FRAME,      LB_REL_PG_FRAME,    RelOrientation::PAGE_FRAME},
     101             :     {SwFPos::REL_PG_PRTAREA,SwFPos::REL_PG_PRTAREA,    LB_REL_PG_PRTAREA,  RelOrientation::PAGE_PRINT_AREA},
     102             :     {SwFPos::REL_CHAR,      SwFPos::REL_CHAR,          LB_REL_CHAR,        RelOrientation::CHAR},
     103             : 
     104             :     {SwFPos::FLY_REL_PG_LEFT,       SwFPos::FLY_MIR_REL_PG_LEFT,    LB_FLY_REL_PG_LEFT,     RelOrientation::PAGE_LEFT},
     105             :     {SwFPos::FLY_REL_PG_RIGHT,      SwFPos::FLY_MIR_REL_PG_RIGHT,   LB_FLY_REL_PG_RIGHT,    RelOrientation::PAGE_RIGHT},
     106             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,       LB_FLY_REL_PG_FRAME,    RelOrientation::PAGE_FRAME},
     107             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_REL_PG_PRTAREA,  RelOrientation::PAGE_PRINT_AREA},
     108             : 
     109             :     {SwFPos::REL_BORDER,        SwFPos::REL_BORDER,             LB_VERT_FRAME,          RelOrientation::FRAME},
     110             :     {SwFPos::REL_PRTAREA,       SwFPos::REL_PRTAREA,            LB_VERT_PRTAREA,        RelOrientation::PRINT_AREA},
     111             : 
     112             :     // #i22305#
     113             :     {SwFPos::FLY_REL_PG_FRAME,      SwFPos::FLY_REL_PG_FRAME,       LB_FLY_VERT_FRAME,      RelOrientation::FRAME},
     114             :     {SwFPos::FLY_REL_PG_PRTAREA,    SwFPos::FLY_REL_PG_PRTAREA,     LB_FLY_VERT_PRTAREA,    RelOrientation::PRINT_AREA},
     115             : 
     116             :     // #i22341#
     117             :     {SwFPos::REL_LINE,  SwFPos::REL_LINE,   LB_VERT_LINE,   RelOrientation::TEXT_LINE}
     118             : };
     119             : 
     120             : static RelationMap aAsCharRelationMap[] =
     121             : {
     122             :     {SwFPos::REL_BASE,  SwFPos::REL_BASE,   LB_REL_BASE,   RelOrientation::FRAME},
     123             :     {SwFPos::REL_CHAR,  SwFPos::REL_CHAR,   LB_REL_CHAR,   RelOrientation::FRAME},
     124             :     {SwFPos::REL_ROW,   SwFPos::REL_ROW,   LB_REL_ROW,     RelOrientation::FRAME}
     125             : };
     126             : 
     127             : /*--------------------------------------------------------------------
     128             :     Anchored at page
     129             :  --------------------------------------------------------------------*/
     130             : 
     131             : #define HORI_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_PG_LEFT| \
     132             :                         LB_REL_PG_RIGHT)
     133             : 
     134             : static FrmMap aHPageMap[] =
     135             : {
     136             :     {SwFPos::LEFT,       SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_PAGE_REL},
     137             :     {SwFPos::RIGHT,      SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_PAGE_REL},
     138             :     {SwFPos::CENTER_HORI,SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_PAGE_REL},
     139             :     {SwFPos::FROMLEFT,   SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_PAGE_REL}
     140             : };
     141             : 
     142             : static FrmMap aHPageHtmlMap[] =
     143             : {
     144             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_REL_PG_FRAME}
     145             : };
     146             : 
     147             : #define VERT_PAGE_REL   (LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     148             : 
     149             : static FrmMap aVPageMap[] =
     150             : {
     151             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_PAGE_REL},
     152             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_PAGE_REL},
     153             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_PAGE_REL},
     154             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_PAGE_REL}
     155             : };
     156             : 
     157             : static FrmMap aVPageHtmlMap[] =
     158             : {
     159             :     {SwFPos::FROMTOP, SwFPos::FROMTOP,        VertOrientation::NONE,      LB_REL_PG_FRAME}
     160             : };
     161             : 
     162             : /*--------------------------------------------------------------------
     163             :     Anchored at frame
     164             :  --------------------------------------------------------------------*/
     165             : 
     166             : #define HORI_FRAME_REL  (LB_FLY_REL_PG_FRAME|LB_FLY_REL_PG_PRTAREA| \
     167             :                         LB_FLY_REL_PG_LEFT|LB_FLY_REL_PG_RIGHT)
     168             : 
     169             : static FrmMap aHFrameMap[] =
     170             : {
     171             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,  HORI_FRAME_REL},
     172             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_FRAME_REL},
     173             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_FRAME_REL},
     174             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_FRAME_REL}
     175             : };
     176             : 
     177             : static FrmMap aHFlyHtmlMap[] =
     178             : {
     179             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      LB_FLY_REL_PG_FRAME},
     180             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_FLY_REL_PG_FRAME}
     181             : };
     182             : 
     183             : // #i18732# - own vertical alignment map for to frame anchored objects
     184             : // #i22305#
     185             : #define VERT_FRAME_REL   (LB_VERT_FRAME|LB_FLY_VERT_PRTAREA)
     186             : 
     187             : static FrmMap aVFrameMap[] =
     188             : {
     189             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_FRAME_REL},
     190             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_FRAME_REL},
     191             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_FRAME_REL},
     192             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_FRAME_REL}
     193             : };
     194             : 
     195             : static FrmMap aVFlyHtmlMap[] =
     196             : {
     197             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       LB_FLY_VERT_FRAME},
     198             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      LB_FLY_VERT_FRAME}
     199             : };
     200             : 
     201             : static FrmMap aVMultiSelectionMap[] =
     202             : {
     203             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      0}
     204             : };
     205             : static FrmMap aHMultiSelectionMap[] =
     206             : {
     207             :     {SwFPos::FROMLEFT,      SwFPos::FROMLEFT,       HoriOrientation::NONE,      0}
     208             : };
     209             : 
     210             : /*--------------------------------------------------------------------
     211             :     Anchored at paragraph
     212             :  --------------------------------------------------------------------*/
     213             : 
     214             : #define HORI_PARA_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     215             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     216             :                         LB_REL_FRM_RIGHT)
     217             : 
     218             : static FrmMap aHParaMap[] =
     219             : {
     220             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_PARA_REL},
     221             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_PARA_REL},
     222             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_PARA_REL},
     223             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_PARA_REL}
     224             : };
     225             : 
     226             : #define HTML_HORI_PARA_REL  (LB_FRAME|LB_PRTAREA)
     227             : 
     228             : static FrmMap aHParaHtmlMap[] =
     229             : {
     230             :     {SwFPos::LEFT,  SwFPos::LEFT,   HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     231             :     {SwFPos::RIGHT, SwFPos::RIGHT,  HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     232             : };
     233             : 
     234             : static FrmMap aHParaHtmlAbsMap[] =
     235             : {
     236             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HTML_HORI_PARA_REL},
     237             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HTML_HORI_PARA_REL}
     238             : };
     239             : 
     240             : 
     241             : #define VERT_PARA_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     242             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     243             : 
     244             : static FrmMap aVParaMap[] =
     245             : {
     246             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       VERT_PARA_REL},
     247             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,    VERT_PARA_REL},
     248             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,    VERT_PARA_REL},
     249             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,      VERT_PARA_REL}
     250             : };
     251             : 
     252             : static FrmMap aVParaHtmlMap[] =
     253             : {
     254             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,       LB_VERT_PRTAREA}
     255             : };
     256             : 
     257             : /*--------------------------------------------------------------------
     258             :     Anchored at character
     259             :  --------------------------------------------------------------------*/
     260             : 
     261             : #define HORI_CHAR_REL   (LB_FRAME|LB_PRTAREA|LB_REL_PG_LEFT|LB_REL_PG_RIGHT| \
     262             :                         LB_REL_PG_FRAME|LB_REL_PG_PRTAREA|LB_REL_FRM_LEFT| \
     263             :                         LB_REL_FRM_RIGHT|LB_REL_CHAR)
     264             : 
     265             : static FrmMap aHCharMap[] =
     266             : {
     267             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,      HORI_CHAR_REL},
     268             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     HORI_CHAR_REL},
     269             :     {SwFPos::CENTER_HORI,   SwFPos::CENTER_HORI,    HoriOrientation::CENTER,    HORI_CHAR_REL},
     270             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      HORI_CHAR_REL}
     271             : };
     272             : 
     273             : #define HTML_HORI_CHAR_REL  (LB_FRAME|LB_PRTAREA|LB_REL_CHAR)
     274             : 
     275             : static FrmMap aHCharHtmlMap[] =
     276             : {
     277             :     {SwFPos::LEFT,          SwFPos::LEFT,           HoriOrientation::LEFT,      HTML_HORI_CHAR_REL},
     278             :     {SwFPos::RIGHT,         SwFPos::RIGHT,          HoriOrientation::RIGHT,     HTML_HORI_CHAR_REL}
     279             : };
     280             : 
     281             : static FrmMap aHCharHtmlAbsMap[] =
     282             : {
     283             :     {SwFPos::LEFT,          SwFPos::MIR_LEFT,       HoriOrientation::LEFT,          LB_PRTAREA|LB_REL_CHAR},
     284             :     {SwFPos::RIGHT,         SwFPos::MIR_RIGHT,      HoriOrientation::RIGHT,     LB_PRTAREA},
     285             :     {SwFPos::FROMLEFT,      SwFPos::MIR_FROMLEFT,   HoriOrientation::NONE,      LB_REL_PG_FRAME}
     286             : };
     287             : 
     288             : // #i18732# - allow vertical alignment at page areas
     289             : // #i22341# - handle <LB_REL_CHAR> on its own
     290             : #define VERT_CHAR_REL   (LB_VERT_FRAME|LB_VERT_PRTAREA| \
     291             :                          LB_REL_PG_FRAME|LB_REL_PG_PRTAREA)
     292             : 
     293             : static FrmMap aVCharMap[] =
     294             : {
     295             :     // #i22341#
     296             :     // introduce mappings for new vertical alignment at top of line <LB_VERT_LINE>
     297             :     // and correct mapping for vertical alignment at character for position <FROM_BOTTOM>
     298             :     // Note: Because of these adjustments the map becomes ambigous in its values
     299             :     //       <eStrId>/<eMirrorStrId> and <nAlign>. These ambiguities are considered
     300             :     //       in the methods <SwFrmPage::FillRelLB(..)>, <SwFrmPage::GetAlignment(..)>
     301             :     //       and <SwFrmPage::FillPosLB(..)>
     302             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           VERT_CHAR_REL|LB_REL_CHAR},
     303             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,        VERT_CHAR_REL|LB_REL_CHAR},
     304             :     {SwFPos::BELOW,         SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     305             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        VERT_CHAR_REL|LB_REL_CHAR},
     306             :     {SwFPos::FROMTOP,       SwFPos::FROMTOP,        VertOrientation::NONE,          VERT_CHAR_REL},
     307             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     VertOrientation::NONE,          LB_REL_CHAR|LB_VERT_LINE},
     308             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_VERT_LINE},
     309             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_VERT_LINE},
     310             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_VERT_LINE}
     311             : };
     312             : 
     313             : 
     314             : static FrmMap aVCharHtmlMap[] =
     315             : {
     316             :     {SwFPos::BELOW,         SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     317             : };
     318             : 
     319             : static FrmMap aVCharHtmlAbsMap[] =
     320             : {
     321             :     {SwFPos::TOP,    SwFPos::TOP,            VertOrientation::TOP,           LB_REL_CHAR},
     322             :     {SwFPos::BELOW,  SwFPos::BELOW,          VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR}
     323             : };
     324             : /*--------------------------------------------------------------------
     325             :     anchored as character
     326             :  --------------------------------------------------------------------*/
     327             : 
     328             : static FrmMap aVAsCharMap[] =
     329             : {
     330             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           LB_REL_BASE},
     331             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::BOTTOM,        LB_REL_BASE},
     332             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        LB_REL_BASE},
     333             : 
     334             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     335             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::CHAR_BOTTOM,   LB_REL_CHAR},
     336             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CHAR_CENTER,   LB_REL_CHAR},
     337             : 
     338             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_REL_ROW},
     339             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     340             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_REL_ROW},
     341             : 
     342             :     {SwFPos::FROMBOTTOM,    SwFPos::FROMBOTTOM,     VertOrientation::NONE,          LB_REL_BASE}
     343             : };
     344             : 
     345             : static FrmMap aVAsCharHtmlMap[] =
     346             : {
     347             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::TOP,           LB_REL_BASE},
     348             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::CENTER,        LB_REL_BASE},
     349             : 
     350             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::CHAR_TOP,      LB_REL_CHAR},
     351             : 
     352             :     {SwFPos::TOP,           SwFPos::TOP,            VertOrientation::LINE_TOP,      LB_REL_ROW},
     353             :     {SwFPos::BOTTOM,        SwFPos::BOTTOM,         VertOrientation::LINE_BOTTOM,   LB_REL_ROW},
     354             :     {SwFPos::CENTER_VERT,   SwFPos::CENTER_VERT,    VertOrientation::LINE_CENTER,   LB_REL_ROW}
     355             : };
     356             : 
     357           0 : static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
     358             : {
     359           0 :     if( pMap )
     360             :     {
     361           0 :         if( pMap == aVParaHtmlMap )
     362           0 :             return SAL_N_ELEMENTS(aVParaHtmlMap);
     363           0 :         if( pMap == aVAsCharHtmlMap )
     364           0 :             return SAL_N_ELEMENTS( aVAsCharHtmlMap );
     365           0 :         if( pMap == aHParaHtmlMap )
     366           0 :             return SAL_N_ELEMENTS( aHParaHtmlMap );
     367           0 :         if( pMap == aHParaHtmlAbsMap )
     368           0 :             return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
     369           0 :         if( pMap == aVPageMap )
     370           0 :             return SAL_N_ELEMENTS( aVPageMap );
     371           0 :         if( pMap == aVPageHtmlMap )
     372           0 :             return SAL_N_ELEMENTS( aVPageHtmlMap );
     373           0 :         if( pMap == aVAsCharMap )
     374           0 :             return SAL_N_ELEMENTS( aVAsCharMap );
     375           0 :         if( pMap == aVParaMap )
     376           0 :             return SAL_N_ELEMENTS( aVParaMap );
     377           0 :         if( pMap == aHParaMap )
     378           0 :             return SAL_N_ELEMENTS( aHParaMap );
     379           0 :         if( pMap == aHFrameMap )
     380           0 :             return SAL_N_ELEMENTS( aHFrameMap );
     381           0 :         if( pMap == aVFrameMap )
     382           0 :             return SAL_N_ELEMENTS( aVFrameMap );
     383           0 :         if( pMap == aHCharMap )
     384           0 :             return SAL_N_ELEMENTS( aHCharMap );
     385           0 :         if( pMap == aHCharHtmlMap )
     386           0 :             return SAL_N_ELEMENTS( aHCharHtmlMap );
     387           0 :         if( pMap == aHCharHtmlAbsMap )
     388           0 :             return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
     389           0 :         if( pMap == aVCharMap )
     390           0 :             return SAL_N_ELEMENTS( aVCharMap );
     391           0 :         if( pMap == aVCharHtmlMap )
     392           0 :             return SAL_N_ELEMENTS( aVCharHtmlMap );
     393           0 :         if( pMap == aVCharHtmlAbsMap )
     394           0 :             return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
     395           0 :         if( pMap == aHPageHtmlMap )
     396           0 :             return SAL_N_ELEMENTS( aHPageHtmlMap );
     397           0 :         if( pMap == aHFlyHtmlMap )
     398           0 :             return SAL_N_ELEMENTS( aHFlyHtmlMap );
     399           0 :         if( pMap == aVFlyHtmlMap )
     400           0 :             return SAL_N_ELEMENTS( aVFlyHtmlMap );
     401           0 :         if( pMap == aVMultiSelectionMap )
     402           0 :             return SAL_N_ELEMENTS( aVMultiSelectionMap );
     403           0 :         if( pMap == aHMultiSelectionMap )
     404           0 :             return SAL_N_ELEMENTS( aHMultiSelectionMap );
     405           0 :         return SAL_N_ELEMENTS(aHPageMap);
     406             :     }
     407           0 :     return 0;
     408             : }
     409             : 
     410           0 : static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
     411             :             SvxSwFramePosString::StringId eStringId, bool bVertical, bool bRTL)
     412             : {
     413             :     //special handling of STR_FROMLEFT
     414           0 :     if(SwFPos::FROMLEFT == eStringId)
     415             :     {
     416             :         eStringId = bVertical ?
     417             :             bRTL ? SwFPos::FROMBOTTOM : SwFPos::FROMTOP :
     418           0 :             bRTL ? SwFPos::FROMRIGHT : SwFPos::FROMLEFT;
     419           0 :         return eStringId;
     420             :     }
     421           0 :     if(bVertical)
     422             :     {
     423             :         //exchange horizontal strings with vertical strings and vice versa
     424             :         static const StringIdPair_Impl aHoriIds[] =
     425             :         {
     426             :             {SwFPos::LEFT,           SwFPos::TOP},
     427             :             {SwFPos::RIGHT,          SwFPos::BOTTOM},
     428             :             {SwFPos::CENTER_HORI,    SwFPos::CENTER_VERT},
     429             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT},
     430             :             {SwFPos::REL_PG_LEFT,    SwFPos::REL_PG_TOP},
     431             :             {SwFPos::REL_PG_RIGHT,   SwFPos::REL_PG_BOTTOM} ,
     432             :             {SwFPos::REL_FRM_LEFT,   SwFPos::REL_FRM_TOP},
     433             :             {SwFPos::REL_FRM_RIGHT,  SwFPos::REL_FRM_BOTTOM}
     434             :         };
     435             :         static const StringIdPair_Impl aVertIds[] =
     436             :         {
     437             :             {SwFPos::TOP,            SwFPos::RIGHT},
     438             :             {SwFPos::BOTTOM,         SwFPos::LEFT },
     439             :             {SwFPos::CENTER_VERT,    SwFPos::CENTER_HORI},
     440             :             {SwFPos::FROMTOP,        SwFPos::FROMRIGHT },
     441             :             {SwFPos::REL_PG_TOP,     SwFPos::REL_PG_LEFT },
     442             :             {SwFPos::REL_PG_BOTTOM,  SwFPos::REL_PG_RIGHT } ,
     443             :             {SwFPos::REL_FRM_TOP,    SwFPos::REL_FRM_LEFT },
     444             :             {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT }
     445             :         };
     446             :         sal_uInt16 nIndex;
     447           0 :         for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex)
     448             :         {
     449           0 :             if(aHoriIds[nIndex].eHori == eStringId)
     450             :             {
     451           0 :                 eStringId = aHoriIds[nIndex].eVert;
     452           0 :                 return eStringId;
     453             :             }
     454             :         }
     455           0 :         nIndex = 0;
     456           0 :         for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex)
     457             :         {
     458           0 :             if(aVertIds[nIndex].eHori == eStringId)
     459             :             {
     460           0 :                 eStringId = aVertIds[nIndex].eVert;
     461           0 :                 break;
     462             :             }
     463             :         }
     464             :     }
     465           0 :     return eStringId;
     466             : }
     467             : // #i22341# - helper method in order to determine all possible
     468             : // listbox relations in a relation map for a given relation
     469           0 : static sal_uLong lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel )
     470             : {
     471           0 :     sal_uLong nLBRelations = 0L;
     472             : 
     473           0 :     for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < SAL_N_ELEMENTS(aRelationMap); ++nRelMapPos )
     474             :     {
     475           0 :         if ( aRelationMap[nRelMapPos].nRelation == _nRel )
     476             :         {
     477           0 :             nLBRelations |= aRelationMap[nRelMapPos].nLBRelation;
     478             :         }
     479             :     }
     480             : 
     481           0 :     return nLBRelations;
     482             : }
     483             : 
     484             : // #i22341# - helper method on order to determine all possible
     485             : // listbox relations in a relation map for a given string ID
     486           0 : static sal_uLong lcl_GetLBRelationsForStrID( const FrmMap* _pMap,
     487             :                                   const SvxSwFramePosString::StringId _eStrId,
     488             :                                   const bool _bUseMirrorStr )
     489             : {
     490           0 :     sal_uLong nLBRelations = 0L;
     491             : 
     492           0 :     std::size_t nRelMapSize = lcl_GetFrmMapCount( _pMap );
     493           0 :     for ( std::size_t nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos )
     494             :     {
     495           0 :         if ( ( !_bUseMirrorStr && _pMap[nRelMapPos].eStrId == _eStrId ) ||
     496           0 :              ( _bUseMirrorStr && _pMap[nRelMapPos].eMirrorStrId == _eStrId ) )
     497             :         {
     498           0 :             nLBRelations |= _pMap[nRelMapPos].nLBRelations;
     499             :         }
     500             :     }
     501             : 
     502           0 :     return nLBRelations;
     503             : }
     504             : 
     505           0 : SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs)
     506             :     : SfxTabPage(pParent, "SwPosSizePage", "cui/ui/swpossizepage.ui", &rInAttrs)
     507             :     , m_pVMap(0)
     508             :     , m_pHMap(0)
     509             :     , m_pSdrView(0)
     510             :     , m_nOldH(HoriOrientation::CENTER)
     511             :     , m_nOldHRel(RelOrientation::FRAME)
     512             :     , m_nOldV(VertOrientation::TOP)
     513             :     , m_nOldVRel(RelOrientation::PRINT_AREA)
     514             :     , m_fWidthHeightRatio(1.0)
     515             :     , m_bHtmlMode(false)
     516             :     , m_bAtHoriPosModified(false)
     517             :     , m_bAtVertPosModified(false)
     518             :     , m_bIsVerticalFrame(false)
     519             :     , m_bPositioningDisabled(false)
     520             :     , m_bIsMultiSelection(false)
     521           0 :     , m_bIsInRightToLeft(false)
     522             : {
     523           0 :     get(m_pWidthMF, "width");
     524           0 :     get(m_pHeightMF, "height");
     525           0 :     get(m_pKeepRatioCB, "ratio");
     526           0 :     get(m_pToPageRB, "topage");
     527           0 :     get(m_pToParaRB, "topara");
     528           0 :     get(m_pToCharRB, "tochar");
     529           0 :     get(m_pAsCharRB, "aschar");
     530           0 :     get(m_pToFrameRB, "toframe");
     531           0 :     get(m_pPositionCB, "pos");
     532           0 :     get(m_pSizeCB, "size");
     533           0 :     get(m_pPosFrame, "posframe");
     534           0 :     get(m_pHoriFT, "horiposft");
     535           0 :     get(m_pHoriLB, "horipos");
     536           0 :     get(m_pHoriByFT, "horibyft");
     537           0 :     get(m_pHoriByMF, "byhori");
     538           0 :     get(m_pHoriToFT, "horitoft");
     539           0 :     get(m_pHoriToLB, "horianchor");
     540           0 :     get(m_pHoriMirrorCB, "mirror");
     541           0 :     get(m_pVertFT, "vertposft");
     542           0 :     get(m_pVertLB, "vertpos");
     543           0 :     get(m_pVertByFT, "vertbyft");
     544           0 :     get(m_pVertByMF, "byvert");
     545           0 :     get(m_pVertToFT, "verttoft");
     546           0 :     get(m_pVertToLB, "vertanchor");
     547           0 :     get(m_pFollowCB, "followtextflow");
     548           0 :     get(m_pExampleWN, "preview");
     549             : 
     550           0 :     setOptimalFrmWidth();
     551           0 :     setOptimalRelWidth();
     552             : 
     553           0 :     FieldUnit eDlgUnit = GetModuleFieldUnit( rInAttrs );
     554           0 :     SetFieldUnit( *m_pHoriByMF, eDlgUnit, true );
     555           0 :     SetFieldUnit( *m_pVertByMF, eDlgUnit, true );
     556           0 :     SetFieldUnit( *m_pWidthMF , eDlgUnit, true );
     557           0 :     SetFieldUnit( *m_pHeightMF, eDlgUnit, true );
     558             : 
     559           0 :     SetExchangeSupport();
     560             : 
     561           0 :     Link aLk = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl);
     562           0 :     m_pWidthMF->SetLoseFocusHdl( aLk );
     563           0 :     m_pHeightMF->SetLoseFocusHdl( aLk );
     564           0 :     m_pHoriByMF->SetLoseFocusHdl( aLk );
     565           0 :     m_pVertByMF->SetLoseFocusHdl( aLk );
     566           0 :     m_pFollowCB->SetClickHdl( aLk );
     567             : 
     568           0 :     aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl);
     569           0 :     m_pWidthMF->SetModifyHdl( aLk );
     570           0 :     m_pHeightMF->SetModifyHdl( aLk );
     571           0 :     m_pHoriByMF->SetModifyHdl( aLk );
     572           0 :     m_pVertByMF->SetModifyHdl( aLk );
     573             : 
     574           0 :     aLk = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl);
     575           0 :     m_pToPageRB->SetClickHdl( aLk );
     576           0 :     m_pToParaRB->SetClickHdl( aLk );
     577           0 :     m_pToCharRB->SetClickHdl( aLk );
     578           0 :     m_pAsCharRB->SetClickHdl( aLk );
     579           0 :     m_pToFrameRB->SetClickHdl( aLk );
     580             : 
     581           0 :     m_pHoriLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
     582           0 :     m_pVertLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl));
     583             : 
     584           0 :     m_pHoriToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
     585           0 :     m_pVertToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl));
     586             : 
     587           0 :     m_pHoriMirrorCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, MirrorHdl));
     588           0 :     m_pPositionCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, ProtectHdl));
     589           0 : }
     590             : 
     591             : namespace
     592             : {
     593             :     struct FrmMaps
     594             :     {
     595             :         FrmMap *pMap;
     596             :         size_t nCount;
     597             :     };
     598             : }
     599             : 
     600           0 : void SvxSwPosSizeTabPage::setOptimalFrmWidth()
     601             : {
     602             :     const FrmMaps aMaps[] = {
     603             :         { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
     604             :         { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
     605             :         { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
     606             :         { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
     607             :         { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
     608             :         { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
     609             :         { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
     610             :         { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFrameMap) },
     611             :         { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
     612             :         { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
     613             :         { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
     614             :         { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
     615             :         { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
     616             :         { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
     617             :         { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
     618             :         { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
     619             :         { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
     620             :         { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
     621             :         { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
     622             :         { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
     623             :         { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
     624           0 :     };
     625             : 
     626           0 :     std::vector<SvxSwFramePosString::StringId> aFrames;
     627           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     628             :     {
     629           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     630             :         {
     631           0 :             aFrames.push_back(aMaps[i].pMap[j].eStrId);
     632           0 :             aFrames.push_back(aMaps[i].pMap[j].eMirrorStrId);
     633             :         }
     634             :     }
     635             : 
     636           0 :     std::sort(aFrames.begin(), aFrames.end());
     637           0 :     aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
     638             : 
     639           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
     640             :         aI != aEnd; ++aI)
     641             :     {
     642           0 :         m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
     643             :     }
     644             : 
     645           0 :     Size aBiggest(m_pHoriLB->GetOptimalSize());
     646           0 :     m_pHoriLB->set_width_request(aBiggest.Width());
     647           0 :     m_pVertLB->set_width_request(aBiggest.Width());
     648           0 :     m_pHoriLB->Clear();
     649           0 : }
     650             : 
     651             : namespace
     652             : {
     653             :     struct RelationMaps
     654             :     {
     655             :         RelationMap *pMap;
     656             :         size_t nCount;
     657             :     };
     658             : }
     659             : 
     660           0 : void SvxSwPosSizeTabPage::setOptimalRelWidth()
     661             : {
     662             :     const RelationMaps aMaps[] = {
     663             :         { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
     664             :         { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
     665           0 :     };
     666             : 
     667           0 :     std::vector<SvxSwFramePosString::StringId> aRels;
     668           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     669             :     {
     670           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     671             :         {
     672           0 :             aRels.push_back(aMaps[i].pMap[j].eStrId);
     673           0 :             aRels.push_back(aMaps[i].pMap[j].eMirrorStrId);
     674             :         }
     675             :     }
     676             : 
     677           0 :     std::sort(aRels.begin(), aRels.end());
     678           0 :     aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
     679             : 
     680           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
     681             :         aI != aEnd; ++aI)
     682             :     {
     683           0 :         m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
     684             :     }
     685             : 
     686           0 :     Size aBiggest(m_pHoriLB->GetOptimalSize());
     687           0 :     m_pHoriLB->set_width_request(aBiggest.Width());
     688           0 :     m_pVertLB->set_width_request(aBiggest.Width());
     689           0 :     m_pHoriLB->Clear();
     690           0 : }
     691             : 
     692           0 : SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage()
     693             : {
     694           0 : }
     695             : 
     696           0 : SfxTabPage* SvxSwPosSizeTabPage::Create( vcl::Window* pParent, const SfxItemSet* rSet)
     697             : {
     698           0 :     return new SvxSwPosSizeTabPage(pParent, *rSet);
     699             : }
     700             : 
     701           0 : const sal_uInt16* SvxSwPosSizeTabPage::GetRanges()
     702             : {
     703             :     static const sal_uInt16 pSwPosRanges[] =
     704             :     {
     705             :         SID_ATTR_TRANSFORM_POS_X,
     706             :         SID_ATTR_TRANSFORM_POS_Y,
     707             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     708             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     709             :         SID_ATTR_TRANSFORM_INTERN,
     710             :         SID_ATTR_TRANSFORM_INTERN,
     711             :         SID_ATTR_TRANSFORM_ANCHOR,
     712             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     713             :         SID_ATTR_TRANSFORM_WIDTH,
     714             :         SID_ATTR_TRANSFORM_SIZE_POINT,
     715             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     716             :         SID_ATTR_TRANSFORM_INTERN,
     717             :         SID_ATTR_TRANSFORM_AUTOWIDTH,
     718             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     719             :         SID_HTML_MODE,
     720             :         SID_HTML_MODE,
     721             :         SID_SW_FOLLOW_TEXT_FLOW,
     722             :         SID_SW_FOLLOW_TEXT_FLOW,
     723             :         SID_ATTR_TRANSFORM_HORI_POSITION,
     724             :         SID_ATTR_TRANSFORM_VERT_POSITION,
     725             :         0
     726             :     };
     727           0 :     return pSwPosRanges;
     728             : }
     729             : 
     730           0 : bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet)
     731             : {
     732           0 :     bool bAnchorChanged = false;
     733           0 :     short nAnchor = GetAnchorType(&bAnchorChanged);
     734           0 :     bool bModified = false;
     735           0 :     if(bAnchorChanged)
     736             :     {
     737           0 :         rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
     738           0 :         bModified = true;
     739             :     }
     740           0 :     if ( m_pPositionCB->IsValueChangedFromSaved() )
     741             :     {
     742           0 :         if( m_pPositionCB->GetState() == TRISTATE_INDET )
     743           0 :             rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
     744             :         else
     745             :             rSet->Put(
     746           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
     747           0 :                 m_pPositionCB->GetState() == TRISTATE_TRUE ? sal_True : sal_False ) );
     748           0 :         bModified = true;
     749             :     }
     750             : 
     751           0 :     if ( m_pSizeCB->IsValueChangedFromSaved() )
     752             :     {
     753           0 :         if ( m_pSizeCB->GetState() == TRISTATE_INDET )
     754           0 :             rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
     755             :         else
     756             :             rSet->Put(
     757           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
     758           0 :                 m_pSizeCB->GetState() == TRISTATE_TRUE ? sal_True : sal_False ) );
     759           0 :         bModified = true;
     760             :     }
     761             : 
     762           0 :     const SfxItemSet& rOldSet = GetItemSet();
     763             : 
     764           0 :     if(!m_bPositioningDisabled)
     765             :     {
     766             :         //on multiple selections the positioning is set via SdrView
     767           0 :         if(m_bIsMultiSelection)
     768             :         {
     769           0 :             if( m_pHoriByMF->IsValueModified() || m_pVertByMF->IsValueModified() )
     770             :             {
     771             :                 long nHoriByPos =
     772           0 :                             static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
     773             :                 long nVertByPos =
     774           0 :                             static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
     775             : 
     776             :                 // old rectangle with CoreUnit
     777           0 :                 m_aRect = m_pSdrView->GetAllMarkedRect();
     778           0 :                 m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
     779             : 
     780           0 :                 nHoriByPos += m_aAnchorPos.X();
     781           0 :                 nVertByPos += m_aAnchorPos.Y();
     782             : 
     783           0 :                 rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) );
     784           0 :                 rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) );
     785             : 
     786           0 :                 bModified = true;
     787             :             }
     788             :         }
     789             :         else
     790             :         {
     791           0 :             if ( m_pHMap )
     792             :             {
     793             :                 const SfxInt16Item& rHoriOrient =
     794           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT));
     795             :                 const SfxInt16Item& rHoriRelation =
     796           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION));
     797             :                 const SfxInt32Item& rHoriPosition =
     798           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ;
     799             : 
     800           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
     801           0 :                 short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
     802           0 :                 short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
     803             :                 const long nHoriByPos =
     804           0 :                             static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
     805           0 :                 if (
     806           0 :                     nAlign != rHoriOrient.GetValue() ||
     807           0 :                     nRel != rHoriRelation.GetValue() ||
     808           0 :                     (m_pHoriByMF->IsEnabled() && nHoriByPos != rHoriPosition.GetValue())
     809             :                    )
     810             :                 {
     811           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign));
     812           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel));
     813           0 :                     if(m_pHoriByMF->IsEnabled())
     814           0 :                         rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos));
     815           0 :                     bModified = true;
     816             :                 }
     817             :             }
     818           0 :             if(m_pHoriMirrorCB->IsEnabled() && m_pHoriMirrorCB->IsValueChangedFromSaved())
     819           0 :                 bModified |= 0 != rSet->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_pHoriMirrorCB->IsChecked()));
     820             : 
     821           0 :             if ( m_pVMap )
     822             :             {
     823             :                 const SfxInt16Item& rVertOrient =
     824           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT));
     825             :                 const SfxInt16Item& rVertRelation =
     826           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION));
     827             :                 const SfxInt32Item& rVertPosition =
     828           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION));
     829             : 
     830           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
     831           0 :                 short nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
     832           0 :                 short nRel = GetRelation(m_pVMap, *m_pVertToLB);
     833             :                 // #i34055# - convert vertical position for
     834             :                 // as-character anchored objects
     835             :                 long nVertByPos =
     836           0 :                         static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
     837           0 :                 if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER )
     838             :                 {
     839           0 :                     nVertByPos *= -1;
     840             :                 }
     841           0 :                 if ( nAlign != rVertOrient.GetValue() ||
     842           0 :                      nRel != rVertRelation.GetValue() ||
     843           0 :                      ( m_pVertByMF->IsEnabled() &&
     844           0 :                        nVertByPos != rVertPosition.GetValue() ) )
     845             :                 {
     846           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign));
     847           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel));
     848           0 :                     if(m_pVertByMF->IsEnabled())
     849           0 :                         rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos));
     850           0 :                     bModified = true;
     851             :                 }
     852             :             }
     853             : 
     854             :             // #i18732#
     855           0 :             if(m_pFollowCB->IsValueChangedFromSaved())
     856             :             {
     857             :                 //Writer internal type - based on SfxBoolItem
     858           0 :                 const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW);
     859           0 :                 if(pItem)
     860             :                 {
     861           0 :                     boost::scoped_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone()));
     862           0 :                     pFollow->SetValue(m_pFollowCB->IsChecked());
     863           0 :                     bModified |= 0 != rSet->Put(*pFollow);
     864             :                 }
     865             :             }
     866             :         }
     867             :     }
     868           0 :     if ( m_pWidthMF->IsValueModified() || m_pHeightMF->IsValueModified() )
     869             :     {
     870           0 :         sal_uInt32 nWidth = static_cast<sal_uInt32>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
     871           0 :         sal_uInt32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
     872           0 :         rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
     873           0 :                         (sal_uInt32) nWidth ) );
     874           0 :         rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
     875           0 :                         (sal_uInt32) nHeight ) );
     876             :         //this item is required by SdrEditView::SetGeoAttrToMarked()
     877           0 :         rSet->Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), RP_LT ) );
     878             : 
     879           0 :         bModified = true;
     880             :     }
     881             : 
     882           0 :     return bModified;
     883             : }
     884             : 
     885           0 : void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet)
     886             : {
     887           0 :     const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_ANCHOR );
     888           0 :     bool bInvalidateAnchor = false;
     889           0 :     short nAnchorType = TextContentAnchorType_AT_PARAGRAPH;
     890           0 :     if(pItem)
     891             :     {
     892           0 :         nAnchorType = static_cast<const SfxInt16Item*>(pItem)->GetValue();
     893           0 :         switch(nAnchorType)
     894             :         {
     895           0 :             case  TextContentAnchorType_AT_PAGE:        m_pToPageRB->Check();  break;
     896           0 :             case  TextContentAnchorType_AT_PARAGRAPH:   m_pToParaRB->Check();  break;
     897           0 :             case  TextContentAnchorType_AT_CHARACTER:   m_pToCharRB->Check();  break;
     898           0 :             case  TextContentAnchorType_AS_CHARACTER:   m_pAsCharRB->Check();  break;
     899           0 :             case  TextContentAnchorType_AT_FRAME:       m_pToFrameRB->Check(); break;
     900           0 :             default : bInvalidateAnchor = true;
     901             :         }
     902           0 :         m_pToPageRB->SaveValue();
     903           0 :         m_pToParaRB->SaveValue();
     904           0 :         m_pToCharRB->SaveValue();
     905           0 :         m_pAsCharRB->SaveValue();
     906           0 :         m_pToFrameRB->SaveValue();
     907             :     }
     908           0 :     if(bInvalidateAnchor)
     909             :     {
     910           0 :         m_pToPageRB->Enable( false );
     911           0 :         m_pToParaRB->Enable( false );
     912           0 :         m_pToCharRB->Enable( false );
     913           0 :         m_pAsCharRB->Enable( false );
     914           0 :         m_pToFrameRB->Enable( false );
     915             :     }
     916             : 
     917           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS );
     918           0 :     if ( pItem )
     919             :     {
     920           0 :         bool bProtected = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     921           0 :         m_pPositionCB->SetState( bProtected ? TRISTATE_TRUE : TRISTATE_FALSE );
     922           0 :         m_pPositionCB->EnableTriState( false );
     923           0 :         m_pSizeCB->Enable( !bProtected );
     924             :     }
     925             :     else
     926             :     {
     927           0 :         m_pPositionCB->SetState( TRISTATE_INDET );
     928             :     }
     929             : 
     930           0 :     m_pPositionCB->SaveValue();
     931             : 
     932           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE );
     933             : 
     934           0 :     if ( pItem )
     935             :     {
     936           0 :         m_pSizeCB->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue()
     937           0 :                               ? TRISTATE_TRUE : TRISTATE_FALSE );
     938           0 :         m_pSizeCB->EnableTriState( false );
     939             :     }
     940             :     else
     941           0 :         m_pSizeCB->SetState( TRISTATE_INDET );
     942           0 :     m_pSizeCB->SaveValue();
     943             : 
     944           0 :     pItem = GetItem( *rSet, SID_HTML_MODE );
     945           0 :     if(pItem)
     946             :     {
     947             :         m_bHtmlMode =
     948           0 :             (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
     949           0 :             != 0;
     950             :     }
     951             : 
     952           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT );
     953           0 :     if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue())
     954             :     {
     955           0 :         OUString sHLabel = m_pHoriFT->GetText();
     956           0 :         m_pHoriFT->SetText(m_pVertFT->GetText());
     957           0 :         m_pVertFT->SetText(sHLabel);
     958           0 :         m_bIsVerticalFrame = true;
     959             :     }
     960           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT);
     961           0 :     if(pItem)
     962           0 :         m_bIsInRightToLeft = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     963             : 
     964           0 :     pItem = GetItem( *rSet, SID_SW_FOLLOW_TEXT_FLOW);
     965           0 :     if(pItem)
     966             :     {
     967             :         const bool bFollowTextFlow =
     968           0 :             static_cast<const SfxBoolItem*>(pItem)->GetValue();
     969           0 :         m_pFollowCB->Check( bFollowTextFlow );
     970             :     }
     971           0 :     m_pFollowCB->SaveValue();
     972             : 
     973           0 :     if(m_bHtmlMode)
     974             :     {
     975           0 :         m_pHoriMirrorCB->Show(false);
     976           0 :         m_pKeepRatioCB->Enable(false);
     977             :         // #i18732# - hide checkbox in HTML mode
     978           0 :         m_pFollowCB->Show(false);
     979             :     }
     980             :     else
     981             :     {
     982             :         // #i18732# correct enable/disable of check box 'Mirror on..'
     983           0 :         m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
     984             : 
     985             :         // #i18732# - enable/disable check box 'Follow text flow'.
     986           0 :         m_pFollowCB->Enable( m_pToParaRB->IsChecked() ||
     987           0 :                                   m_pToCharRB->IsChecked() );
     988             :     }
     989             : 
     990           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_WIDTH );
     991           0 :     sal_Int32 nWidth = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
     992             : 
     993           0 :     m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
     994             : 
     995           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HEIGHT );
     996           0 :     sal_Int32 nHeight = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
     997           0 :     m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
     998           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
     999             : 
    1000           0 :     if(!m_bPositioningDisabled)
    1001             :     {
    1002           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_ORIENT);
    1003           0 :         if(pItem)
    1004             :         {
    1005           0 :             short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1006           0 :             m_nOldH = nHoriOrientation;
    1007             :         }
    1008           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_ORIENT);
    1009           0 :         if(pItem)
    1010             :         {
    1011           0 :             short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1012           0 :             m_nOldV = nVertOrientation;
    1013             :         }
    1014           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_RELATION);
    1015           0 :         if(pItem)
    1016             :         {
    1017           0 :             m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1018             :         }
    1019             : 
    1020           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_RELATION);
    1021           0 :         if(pItem)
    1022             :         {
    1023           0 :             m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1024             :         }
    1025           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR);
    1026           0 :         if(pItem)
    1027           0 :             m_pHoriMirrorCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
    1028           0 :         m_pHoriMirrorCB->SaveValue();
    1029             : 
    1030           0 :         sal_Int32 nHoriPos = 0;
    1031           0 :         sal_Int32 nVertPos = 0;
    1032           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_POSITION);
    1033           0 :         if(pItem)
    1034           0 :             nHoriPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
    1035           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_POSITION);
    1036           0 :         if(pItem)
    1037           0 :             nVertPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
    1038             : 
    1039           0 :         InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos);
    1040             : 
    1041           0 :         m_pVertByMF->SaveValue();
    1042           0 :         m_pHoriByMF->SaveValue();
    1043             :         // #i18732#
    1044           0 :         m_pFollowCB->SaveValue();
    1045             : 
    1046           0 :         RangeModifyHdl(m_pWidthMF);  // initially set maximum values
    1047             :     }
    1048           0 : }
    1049             : 
    1050           0 : int  SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
    1051             : {
    1052           0 :     if( _pSet )
    1053           0 :         FillItemSet( _pSet );
    1054           0 :     return( LEAVE_PAGE );
    1055             : }
    1056             : 
    1057           0 : void SvxSwPosSizeTabPage::EnableAnchorTypes(sal_uInt16 nAnchorEnable)
    1058             : {
    1059           0 :     if((nAnchorEnable & SVX_OBJ_AT_FLY))
    1060           0 :         m_pToFrameRB->Show();
    1061           0 :     if(!(nAnchorEnable & SVX_OBJ_PAGE))
    1062           0 :         m_pToPageRB->Enable(false);
    1063           0 : }
    1064             : 
    1065           0 : short SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged)
    1066             : {
    1067           0 :     short nRet = -1;
    1068           0 :     RadioButton* pCheckedButton = 0;
    1069           0 :     if(m_pToParaRB->IsEnabled())
    1070             :     {
    1071           0 :         if(m_pToPageRB->IsChecked())
    1072             :         {
    1073           0 :             nRet = TextContentAnchorType_AT_PAGE;
    1074           0 :             pCheckedButton = m_pToPageRB;
    1075             :         }
    1076           0 :         else if(m_pToParaRB->IsChecked())
    1077             :         {
    1078           0 :             nRet = TextContentAnchorType_AT_PARAGRAPH;
    1079           0 :             pCheckedButton = m_pToParaRB;
    1080             :         }
    1081           0 :         else if(m_pToCharRB->IsChecked())
    1082             :         {
    1083           0 :             nRet = TextContentAnchorType_AT_CHARACTER;
    1084           0 :             pCheckedButton = m_pToCharRB;
    1085             :         }
    1086           0 :         else if(m_pAsCharRB->IsChecked())
    1087             :         {
    1088           0 :             nRet = TextContentAnchorType_AS_CHARACTER;
    1089           0 :             pCheckedButton = m_pAsCharRB;
    1090             :         }
    1091           0 :         else if(m_pToFrameRB->IsChecked())
    1092             :         {
    1093           0 :             nRet = TextContentAnchorType_AT_FRAME;
    1094           0 :             pCheckedButton = m_pToFrameRB;
    1095             :         }
    1096             :     }
    1097           0 :     if(pbHasChanged)
    1098             :     {
    1099           0 :          if(pCheckedButton)
    1100           0 :              *pbHasChanged = pCheckedButton->IsValueChangedFromSaved();
    1101             :          else
    1102           0 :              *pbHasChanged = false;
    1103             :     }
    1104           0 :    return nRet;
    1105             : }
    1106             : 
    1107           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl)
    1108             : {
    1109           0 :     if(m_bPositioningDisabled)
    1110           0 :         return 0;
    1111           0 :     SvxSwFrameValidation        aVal;
    1112             : 
    1113           0 :     aVal.nAnchorType = GetAnchorType();
    1114           0 :     aVal.bAutoHeight = false;
    1115           0 :     aVal.bAutoWidth = false;
    1116           0 :     aVal.bMirror = m_pHoriMirrorCB->IsChecked();
    1117             :     // #i18732#
    1118           0 :     aVal.bFollowTextFlow = m_pFollowCB->IsChecked();
    1119             : 
    1120           0 :     if ( m_pHMap )
    1121             :     {
    1122             :         // horizontal alignment
    1123           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriToLB);
    1124           0 :         sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
    1125           0 :         sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1126             : 
    1127           0 :         aVal.nHoriOrient = (short)nAlign;
    1128           0 :         aVal.nHRelOrient = (short)nRel;
    1129             :     }
    1130             :     else
    1131           0 :         aVal.nHoriOrient = HoriOrientation::NONE;
    1132             : 
    1133           0 :     if ( m_pVMap )
    1134             :     {
    1135             :         // vertical alignment
    1136           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
    1137           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
    1138           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
    1139             : 
    1140           0 :         aVal.nVertOrient = (short)nAlign;
    1141           0 :         aVal.nVRelOrient = (short)nRel;
    1142             :     }
    1143             :     else
    1144           0 :         aVal.nVertOrient = VertOrientation::NONE;
    1145             : 
    1146             :     const long nAtHorzPosVal =
    1147           0 :                     static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
    1148             :     const long nAtVertPosVal =
    1149           0 :                     static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
    1150             : 
    1151           0 :     aVal.nHPos = nAtHorzPosVal;
    1152           0 :     aVal.nVPos = nAtVertPosVal;
    1153             : 
    1154           0 :     sal_Int32 nWidth = static_cast<sal_uInt32>(m_pWidthMF-> Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
    1155           0 :     sal_Int32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
    1156           0 :     aVal.nWidth  = nWidth;
    1157           0 :     aVal.nHeight = nHeight;
    1158             : 
    1159           0 :     if(m_aValidateLink.IsSet())
    1160           0 :         m_aValidateLink.Call(&aVal);
    1161             : 
    1162           0 :     nWidth = aVal.nWidth;
    1163           0 :     nHeight = aVal.nHeight;
    1164             : 
    1165             :     // minimum width also for style
    1166           0 :     m_pHeightMF->SetMin(m_pHeightMF->Normalize(aVal.nMinHeight), FUNIT_TWIP);
    1167           0 :     m_pWidthMF-> SetMin(m_pWidthMF->Normalize(aVal.nMinWidth), FUNIT_TWIP);
    1168             : 
    1169           0 :     sal_Int32 nMaxWidth(aVal.nMaxWidth);
    1170           0 :     sal_Int32 nMaxHeight(aVal.nMaxHeight);
    1171             : 
    1172           0 :     sal_Int64 nTmp = m_pHeightMF->Normalize(nMaxHeight);
    1173           0 :     m_pHeightMF->SetMax(nTmp, FUNIT_TWIP);
    1174             : 
    1175           0 :     nTmp = m_pWidthMF->Normalize(nMaxWidth);
    1176           0 :     m_pWidthMF->SetMax(nTmp, FUNIT_TWIP);
    1177             : 
    1178           0 :     m_pHoriByMF->SetMin(m_pHoriByMF->Normalize(aVal.nMinHPos), FUNIT_TWIP);
    1179           0 :     m_pHoriByMF->SetMax(m_pHoriByMF->Normalize(aVal.nMaxHPos), FUNIT_TWIP);
    1180           0 :     if ( aVal.nHPos != nAtHorzPosVal )
    1181           0 :         m_pHoriByMF->SetValue(m_pHoriByMF->Normalize(aVal.nHPos), FUNIT_TWIP);
    1182             : 
    1183           0 :     m_pVertByMF->SetMin(m_pVertByMF->Normalize(aVal.nMinVPos ), FUNIT_TWIP);
    1184           0 :     m_pVertByMF->SetMax(m_pVertByMF->Normalize(aVal.nMaxVPos), FUNIT_TWIP);
    1185           0 :     if ( aVal.nVPos != nAtVertPosVal )
    1186           0 :         m_pVertByMF->SetValue(m_pVertByMF->Normalize(aVal.nVPos), FUNIT_TWIP);
    1187             : 
    1188           0 :     return 0;
    1189             : }
    1190             : 
    1191           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl)
    1192             : {
    1193           0 :     m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
    1194             : 
    1195             :     // #i18732# - enable check box 'Follow text flow' for anchor
    1196             :     // type to-paragraph' and to-character
    1197           0 :     m_pFollowCB->Enable( m_pToParaRB->IsChecked() || m_pToCharRB->IsChecked() );
    1198             : 
    1199           0 :     short nId = GetAnchorType();
    1200             : 
    1201           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1202           0 :     RangeModifyHdl(0);
    1203             : 
    1204           0 :     if(m_bHtmlMode)
    1205             :     {
    1206           0 :         PosHdl(m_pHoriLB);
    1207           0 :         PosHdl(m_pVertLB);
    1208             :     }
    1209           0 :     return 0;
    1210             : }
    1211             : 
    1212           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl)
    1213             : {
    1214           0 :     short nId = GetAnchorType();
    1215           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1216             : 
    1217           0 :     return 0;
    1218             : }
    1219             : 
    1220           0 : IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox *, pLB )
    1221             : {
    1222           0 :     bool bHori = pLB == m_pHoriToLB;
    1223             : 
    1224           0 :     UpdateExample();
    1225             : 
    1226           0 :     if (bHori)
    1227           0 :         m_bAtHoriPosModified = true;
    1228             :     else
    1229           0 :         m_bAtVertPosModified = true;
    1230             : 
    1231           0 :     if(m_bHtmlMode  && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) // again special treatment
    1232             :     {
    1233           0 :         if(bHori)
    1234             :         {
    1235           0 :             sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1236           0 :             if(RelOrientation::PRINT_AREA == nRel && 0 == m_pVertLB->GetSelectEntryPos())
    1237             :             {
    1238           0 :                 m_pVertLB->SelectEntryPos(1);
    1239             :             }
    1240           0 :             else if(RelOrientation::CHAR == nRel && 1 == m_pVertLB->GetSelectEntryPos())
    1241             :             {
    1242           0 :                 m_pVertLB->SelectEntryPos(0);
    1243             :             }
    1244             :         }
    1245             :     }
    1246           0 :     if (pLB)    // only if the hanlder has been called by a change of the controller
    1247           0 :         RangeModifyHdl(0);
    1248             : 
    1249           0 :     return 0;
    1250             : 
    1251             : }
    1252             : 
    1253           0 : IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox *, pLB )
    1254             : {
    1255           0 :     bool bHori = pLB == m_pHoriLB;
    1256           0 :     ListBox *pRelLB = bHori ? m_pHoriToLB : m_pVertToLB;
    1257           0 :     FixedText *pRelFT = bHori ? m_pHoriToFT : m_pVertToFT;
    1258           0 :     FrmMap *pMap = bHori ? m_pHMap : m_pVMap;
    1259             : 
    1260             : 
    1261           0 :     sal_uInt16 nMapPos = GetMapPos(pMap, *pLB);
    1262           0 :     sal_uInt16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
    1263             : 
    1264           0 :     if (bHori)
    1265             :     {
    1266           0 :         bool bEnable = HoriOrientation::NONE == nAlign;
    1267           0 :         m_pHoriByMF->Enable( bEnable );
    1268           0 :         m_pHoriByFT->Enable( bEnable );
    1269             :     }
    1270             :     else
    1271             :     {
    1272           0 :         bool bEnable = VertOrientation::NONE == nAlign;
    1273           0 :         m_pVertByMF->Enable( bEnable );
    1274           0 :         m_pVertByFT->Enable( bEnable );
    1275             :     }
    1276             : 
    1277           0 :     RangeModifyHdl( 0 );
    1278             : 
    1279           0 :     short nRel = 0;
    1280           0 :     if (pLB->GetSelectEntryCount())
    1281             :     {
    1282             : 
    1283           0 :         if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1284           0 :             nRel = ((RelationMap *)pRelLB->GetEntryData(pRelLB->GetSelectEntryPos()))->nRelation;
    1285             : 
    1286           0 :         FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
    1287             :     }
    1288             :     else
    1289           0 :         pRelLB->Clear();
    1290             : 
    1291           0 :     UpdateExample();
    1292             : 
    1293           0 :     if (bHori)
    1294           0 :         m_bAtHoriPosModified = true;
    1295             :     else
    1296           0 :         m_bAtVertPosModified = true;
    1297             : 
    1298             :     // special treatment for HTML-Mode with horz-vert-dependencies
    1299           0 :     if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType())
    1300             :     {
    1301           0 :         bool bSet = false;
    1302           0 :         if(bHori)
    1303             :         {
    1304             :             // on the right only below is allowed - from the left only at the top
    1305             :             // from the left at the character -> below
    1306           0 :             if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) &&
    1307           0 :                     0 == m_pVertLB->GetSelectEntryPos())
    1308             :             {
    1309           0 :                 if(RelOrientation::FRAME == nRel)
    1310           0 :                     m_pVertLB->SelectEntryPos(1);
    1311             :                 else
    1312           0 :                     m_pVertLB->SelectEntryPos(0);
    1313           0 :                 bSet = true;
    1314             :             }
    1315           0 :             else if(HoriOrientation::LEFT == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
    1316             :             {
    1317           0 :                 m_pVertLB->SelectEntryPos(0);
    1318           0 :                 bSet = true;
    1319             :             }
    1320           0 :             else if(HoriOrientation::NONE == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
    1321             :             {
    1322           0 :                 m_pVertLB->SelectEntryPos(0);
    1323           0 :                 bSet = true;
    1324             :             }
    1325           0 :             if(bSet)
    1326           0 :                 PosHdl(m_pVertLB);
    1327             :         }
    1328             :         else
    1329             :         {
    1330           0 :             if(VertOrientation::TOP == nAlign)
    1331             :             {
    1332           0 :                 if(1 == m_pHoriLB->GetSelectEntryPos())
    1333             :                 {
    1334           0 :                     m_pHoriLB->SelectEntryPos(0);
    1335           0 :                     bSet = true;
    1336             :                 }
    1337           0 :                 m_pHoriToLB->SelectEntryPos(1);
    1338             :             }
    1339           0 :             else if(VertOrientation::CHAR_BOTTOM == nAlign)
    1340             :             {
    1341           0 :                 if(2 == m_pHoriLB->GetSelectEntryPos())
    1342             :                 {
    1343           0 :                     m_pHoriLB->SelectEntryPos(0);
    1344           0 :                     bSet = true;
    1345             :                 }
    1346           0 :                 m_pHoriToLB->SelectEntryPos(0) ;
    1347             :             }
    1348           0 :             if(bSet)
    1349           0 :                 PosHdl(m_pHoriLB);
    1350             :         }
    1351             : 
    1352             :     }
    1353           0 :     return 0;
    1354             : }
    1355             : 
    1356           0 : IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, Edit *, pEdit )
    1357             : {
    1358           0 :     sal_Int64 nWidth = m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP));
    1359           0 :     sal_Int64 nHeight = m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP));
    1360           0 :     if ( m_pKeepRatioCB->IsChecked() )
    1361             :     {
    1362           0 :         if ( pEdit == m_pWidthMF )
    1363             :         {
    1364           0 :             nHeight = sal_Int64((double)nWidth / m_fWidthHeightRatio);
    1365           0 :             m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
    1366             :         }
    1367           0 :         else if(pEdit == m_pHeightMF)
    1368             :         {
    1369           0 :             nWidth = sal_Int64((double)nHeight * m_fWidthHeightRatio);
    1370           0 :             m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
    1371             :         }
    1372             :     }
    1373           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    1374           0 :     UpdateExample();
    1375           0 :     return 0;
    1376             : }
    1377             : 
    1378           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl)
    1379             : {
    1380           0 :     m_pSizeCB->Enable(m_pPositionCB->IsEnabled() && !m_pPositionCB->IsChecked());
    1381           0 :     return 0;
    1382             : }
    1383             : 
    1384           0 : short SvxSwPosSizeTabPage::GetRelation(FrmMap *, ListBox &rRelationLB)
    1385             : {
    1386           0 :     short nRel = 0;
    1387           0 :     sal_Int32 nPos = rRelationLB.GetSelectEntryPos();
    1388             : 
    1389           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1390             :     {
    1391           0 :         RelationMap *pEntry = (RelationMap *)rRelationLB.GetEntryData(nPos);
    1392           0 :         nRel = pEntry->nRelation;
    1393             :     }
    1394             : 
    1395           0 :     return nRel;
    1396             : }
    1397             : 
    1398           0 : short SvxSwPosSizeTabPage::GetAlignment(FrmMap *pMap, sal_uInt16 nMapPos, ListBox &/*rAlignLB*/, ListBox &rRelationLB)
    1399             : {
    1400           0 :     short nAlign = 0;
    1401             : 
    1402             :     // #i22341# - special handling also for map <aVCharMap>,
    1403             :     // because it contains ambigous items for alignment
    1404           0 :     if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap ||
    1405             :             pMap == aVCharMap )
    1406             :     {
    1407           0 :         if (rRelationLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1408             :         {
    1409           0 :             sal_uLong  nRel = ((RelationMap *)rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos()))->nLBRelation;
    1410           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1411           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1412             : 
    1413           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1414             :             {
    1415           0 :                 if (pMap[i].eStrId == eStrId)
    1416             :                 {
    1417           0 :                     sal_uLong nLBRelations = pMap[i].nLBRelations;
    1418           0 :                     if (nLBRelations & nRel)
    1419             :                     {
    1420           0 :                         nAlign = pMap[i].nAlign;
    1421           0 :                         break;
    1422             :                     }
    1423             :                 }
    1424             :             }
    1425           0 :         }
    1426             :     }
    1427           0 :     else if (pMap)
    1428           0 :         nAlign = pMap[nMapPos].nAlign;
    1429             : 
    1430           0 :     return nAlign;
    1431             : }
    1432             : 
    1433           0 : sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap *pMap, ListBox &rAlignLB)
    1434             : {
    1435           0 :     sal_uInt16 nMapPos = 0;
    1436           0 :     sal_Int32 nLBSelPos = rAlignLB.GetSelectEntryPos();
    1437             : 
    1438           0 :     if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
    1439             :     {
    1440           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1441             :         {
    1442           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1443           0 :             OUString sSelEntry(rAlignLB.GetSelectEntry());
    1444             : 
    1445           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1446             :             {
    1447           0 :                 SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
    1448             : 
    1449           0 :                 OUString sEntry = m_aFramePosString.GetString(eResId);
    1450             : 
    1451           0 :                 if (sEntry == sSelEntry)
    1452             :                 {
    1453           0 :                     nMapPos = sal::static_int_cast< sal_uInt16 >(i);
    1454           0 :                     break;
    1455             :                 }
    1456           0 :             }
    1457             :         }
    1458             :         else
    1459           0 :             nMapPos = nLBSelPos;
    1460             :     }
    1461             : 
    1462           0 :     return nMapPos;
    1463             : }
    1464             : 
    1465           0 : void SvxSwPosSizeTabPage::InitPos(short nAnchor,
    1466             :                                 sal_uInt16 nH,
    1467             :                                 sal_uInt16 nHRel,
    1468             :                                 sal_uInt16 nV,
    1469             :                                 sal_uInt16 nVRel,
    1470             :                                 long   nX,
    1471             :                                 long   nY)
    1472             : {
    1473           0 :     sal_Int32 nPos = m_pVertLB->GetSelectEntryPos();
    1474           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pVMap )
    1475             :     {
    1476           0 :         m_nOldV    = m_pVMap[nPos].nAlign;
    1477           0 :         nPos = m_pVertToLB->GetSelectEntryPos();
    1478           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1479           0 :             m_nOldVRel = ((RelationMap *)m_pVertToLB->GetEntryData(nPos))->nRelation;
    1480             :     }
    1481             : 
    1482           0 :     nPos = m_pHoriLB->GetSelectEntryPos();
    1483           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pHMap )
    1484             :     {
    1485           0 :         m_nOldH    = m_pHMap[nPos].nAlign;
    1486             : 
    1487           0 :         nPos = m_pHoriToLB->GetSelectEntryPos();
    1488           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1489           0 :             m_nOldHRel = ((RelationMap *)m_pHoriToLB->GetEntryData(nPos))->nRelation;
    1490             :     }
    1491             : 
    1492           0 :     bool bEnable = true;
    1493           0 :     if( m_bIsMultiSelection )
    1494             :     {
    1495           0 :         m_pVMap = aVMultiSelectionMap;
    1496           0 :         m_pHMap = aHMultiSelectionMap;
    1497             :     }
    1498           0 :     else if( nAnchor == TextContentAnchorType_AT_PAGE )
    1499             :     {
    1500           0 :         m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap;
    1501           0 :         m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap;
    1502             :     }
    1503           0 :     else if ( nAnchor == TextContentAnchorType_AT_FRAME )
    1504             :     {
    1505             :         // #i18732# - own vertical alignment map for to frame
    1506             :         // anchored objects.
    1507           0 :         m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
    1508           0 :         m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
    1509             :     }
    1510           0 :     else if ( nAnchor == TextContentAnchorType_AT_PARAGRAPH )
    1511             :     {
    1512           0 :         if(m_bHtmlMode)
    1513             :         {
    1514           0 :             m_pVMap = aVParaHtmlMap;
    1515           0 :             m_pHMap = aHParaHtmlAbsMap;
    1516             :         }
    1517             :         else
    1518             :         {
    1519           0 :             m_pVMap = aVParaMap;
    1520           0 :             m_pHMap = aHParaMap;
    1521             :         }
    1522             :     }
    1523           0 :     else if ( nAnchor == TextContentAnchorType_AT_CHARACTER )
    1524             :     {
    1525           0 :         if(m_bHtmlMode)
    1526             :         {
    1527           0 :             m_pVMap = aVCharHtmlAbsMap;
    1528           0 :             m_pHMap = aHCharHtmlAbsMap;
    1529             :         }
    1530             :         else
    1531             :         {
    1532           0 :             m_pVMap = aVCharMap;
    1533           0 :             m_pHMap = aHCharMap;
    1534             :         }
    1535             :     }
    1536           0 :     else if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1537             :     {
    1538           0 :         m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap     : aVAsCharMap;
    1539           0 :         m_pHMap = 0;
    1540           0 :         bEnable = false;
    1541             :     }
    1542           0 :     m_pHoriLB->Enable( bEnable );
    1543           0 :     m_pHoriFT->Enable( bEnable );
    1544             : 
    1545             :     // select current Pos
    1546             :     // horizontal
    1547           0 :     if ( nH == USHRT_MAX )
    1548             :     {
    1549           0 :         nH    = m_nOldH;
    1550           0 :         nHRel = m_nOldHRel;
    1551             :     }
    1552             :     // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB>
    1553           0 :     sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_pHoriLB);
    1554           0 :     FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_pHoriToLB, *m_pHoriToFT);
    1555             : 
    1556             :     // vertical
    1557           0 :     if ( nV == USHRT_MAX )
    1558             :     {
    1559           0 :         nV    = m_nOldV;
    1560           0 :         nVRel = m_nOldVRel;
    1561             :     }
    1562             :     // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB>
    1563           0 :     nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_pVertLB);
    1564           0 :     FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_pVertToLB, *m_pVertToFT);
    1565             : 
    1566             :     // Edits init
    1567           0 :     bEnable = nH == HoriOrientation::NONE &&
    1568           0 :             nAnchor != TextContentAnchorType_AS_CHARACTER;//#61359# why not in formats&& !bFormat;
    1569           0 :     if (!bEnable)
    1570             :     {
    1571           0 :         m_pHoriByMF->SetValue( 0, FUNIT_TWIP );
    1572           0 :         if (nX != LONG_MAX && m_bHtmlMode)
    1573           0 :             m_pHoriByMF->SetModifyFlag();
    1574             :     }
    1575           0 :     else if(m_bIsMultiSelection)
    1576             :     {
    1577           0 :          m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(m_aRect.Left()), FUNIT_TWIP );
    1578             :     }
    1579             :     else
    1580             :     {
    1581           0 :         if (nX != LONG_MAX)
    1582           0 :             m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(nX), FUNIT_TWIP );
    1583             :     }
    1584           0 :     m_pHoriByFT->Enable( bEnable );
    1585           0 :     m_pHoriByMF->Enable( bEnable );
    1586             : 
    1587           0 :     bEnable = nV == VertOrientation::NONE;
    1588           0 :     if ( !bEnable )
    1589             :     {
    1590           0 :         m_pVertByMF->SetValue( 0, FUNIT_TWIP );
    1591           0 :         if(nY != LONG_MAX && m_bHtmlMode)
    1592           0 :             m_pVertByMF->SetModifyFlag();
    1593             :     }
    1594           0 :     else if(m_bIsMultiSelection)
    1595             :     {
    1596           0 :          m_pVertByMF->SetValue( m_pVertByMF->Normalize(m_aRect.Top()), FUNIT_TWIP );
    1597             :     }
    1598             :     else
    1599             :     {
    1600           0 :         if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1601             :         {
    1602           0 :             if ( nY == LONG_MAX )
    1603           0 :                 nY = 0;
    1604             :             else
    1605           0 :                 nY *= -1;
    1606             :         }
    1607           0 :         if ( nY != LONG_MAX )
    1608           0 :             m_pVertByMF->SetValue( m_pVertByMF->Normalize(nY), FUNIT_TWIP );
    1609             :     }
    1610           0 :     m_pVertByFT->Enable( bEnable );
    1611           0 :     m_pVertByMF->Enable( bEnable );
    1612           0 :     UpdateExample();
    1613           0 : }
    1614             : 
    1615           0 : void SvxSwPosSizeTabPage::UpdateExample()
    1616             : {
    1617           0 :     sal_Int32 nPos = m_pHoriLB->GetSelectEntryPos();
    1618           0 :     if ( m_pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1619             :     {
    1620           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
    1621           0 :         short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
    1622           0 :         short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1623             : 
    1624           0 :         m_pExampleWN->SetHAlign(nAlign);
    1625           0 :         m_pExampleWN->SetHoriRel(nRel);
    1626             :     }
    1627             : 
    1628           0 :     nPos = m_pVertLB->GetSelectEntryPos();
    1629           0 :     if ( m_pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1630             :     {
    1631           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
    1632           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
    1633           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
    1634             : 
    1635           0 :         m_pExampleWN->SetVAlign(nAlign);
    1636           0 :         m_pExampleWN->SetVertRel(nRel);
    1637             :     }
    1638             : 
    1639             :     // Size
    1640           0 :     long nXPos = static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
    1641           0 :     long nYPos = static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
    1642           0 :     m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
    1643             : 
    1644           0 :     m_pExampleWN->SetAnchor( GetAnchorType() );
    1645           0 :     m_pExampleWN->Invalidate();
    1646           0 : }
    1647             : 
    1648           0 : sal_uLong SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign,
    1649             :         sal_uInt16 nRel, ListBox &rLB, FixedText &rFT)
    1650             : {
    1651           0 :     OUString sSelEntry;
    1652           0 :     sal_uLong  nLBRelations = 0;
    1653           0 :     std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1654             : 
    1655           0 :     rLB.Clear();
    1656             : 
    1657           0 :     if (nMapPos < nMapCount)
    1658             :     {
    1659           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1660             :         {
    1661           0 :             OUString sOldEntry(rLB.GetSelectEntry());
    1662           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
    1663           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1664             : 
    1665           0 :             for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++)
    1666             :             {
    1667           0 :                 if (pMap[_nMapPos].eStrId == eStrId)
    1668             :                 {
    1669           0 :                     nLBRelations = pMap[_nMapPos].nLBRelations;
    1670           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1671             :                     {
    1672           0 :                         if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
    1673             :                         {
    1674           0 :                             SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
    1675             : 
    1676           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1677           0 :                             OUString sEntry = m_aFramePosString.GetString(sStrId1);
    1678           0 :                             sal_Int32 nPos = rLB.InsertEntry(sEntry);
    1679           0 :                             rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
    1680           0 :                             if (pMap[_nMapPos].nAlign == nAlign)
    1681           0 :                                 sSelEntry = sEntry;
    1682           0 :                             break;
    1683             :                         }
    1684             :                     }
    1685             :                 }
    1686             :             }
    1687           0 :             if (!sSelEntry.isEmpty())
    1688           0 :                 rLB.SelectEntry(sSelEntry);
    1689             :             else
    1690             :             {
    1691           0 :                 rLB.SelectEntry(sOldEntry);
    1692             : 
    1693           0 :                 if (!rLB.GetSelectEntryCount())
    1694             :                 {
    1695           0 :                     for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
    1696             :                     {
    1697           0 :                         RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
    1698           0 :                         if (pEntry->nLBRelation == LB_REL_CHAR) // Default
    1699             :                         {
    1700           0 :                             rLB.SelectEntryPos(i);
    1701           0 :                             break;
    1702             :                         }
    1703             :                     }
    1704             :                 }
    1705           0 :             }
    1706             :         }
    1707             :         else
    1708             :         {
    1709           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aRelationMap);
    1710             : 
    1711             :             // #i22341# - special handling for map <aVCharMap>,
    1712             :             // because its ambigous in its <eStrId>/<eMirrorStrId>.
    1713           0 :             if ( pMap == aVCharMap )
    1714             :             {
    1715             :                 nLBRelations = ::lcl_GetLBRelationsForStrID( pMap,
    1716           0 :                                              ( m_pHoriMirrorCB->IsChecked()
    1717           0 :                                                ? pMap[nMapPos].eMirrorStrId
    1718           0 :                                                : pMap[nMapPos].eStrId ),
    1719           0 :                                              m_pHoriMirrorCB->IsChecked() );
    1720             :             }
    1721             :             else
    1722             :             {
    1723           0 :                 nLBRelations = pMap[nMapPos].nLBRelations;
    1724             :             }
    1725             : 
    1726           0 :             for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
    1727             :             {
    1728           0 :                 if (nLBRelations & nBit)
    1729             :                 {
    1730           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1731             :                     {
    1732           0 :                         if (aRelationMap[nRelPos].nLBRelation == nBit)
    1733             :                         {
    1734           0 :                             SvxSwFramePosString::StringId sStrId1 = m_pHoriMirrorCB->IsChecked() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
    1735           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1736           0 :                             OUString sEntry = m_aFramePosString.GetString(sStrId1);
    1737           0 :                             sal_Int32 nPos = rLB.InsertEntry(sEntry);
    1738           0 :                             rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
    1739           0 :                             if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel)
    1740           0 :                                 sSelEntry = sEntry;
    1741             :                         }
    1742             :                     }
    1743             :                 }
    1744             :             }
    1745           0 :             if (!sSelEntry.isEmpty())
    1746           0 :                 rLB.SelectEntry(sSelEntry);
    1747             :             else
    1748             :             {
    1749             :                 // Probably anchor change. So look for a similar relation.
    1750           0 :                 switch (nRel)
    1751             :                 {
    1752           0 :                     case RelOrientation::FRAME:           nRel = RelOrientation::PAGE_FRAME;    break;
    1753           0 :                     case RelOrientation::PRINT_AREA:      nRel = RelOrientation::PAGE_PRINT_AREA;  break;
    1754           0 :                     case RelOrientation::PAGE_LEFT:       nRel = RelOrientation::FRAME_LEFT;    break;
    1755           0 :                     case RelOrientation::PAGE_RIGHT:      nRel = RelOrientation::FRAME_RIGHT;   break;
    1756           0 :                     case RelOrientation::FRAME_LEFT:      nRel = RelOrientation::PAGE_LEFT;     break;
    1757           0 :                     case RelOrientation::FRAME_RIGHT:     nRel = RelOrientation::PAGE_RIGHT;    break;
    1758           0 :                     case RelOrientation::PAGE_FRAME:      nRel = RelOrientation::FRAME;           break;
    1759           0 :                     case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA;         break;
    1760             : 
    1761             :                     default:
    1762           0 :                         if (rLB.GetEntryCount())
    1763             :                         {
    1764           0 :                             RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(rLB.GetEntryCount() - 1);
    1765           0 :                             nRel = pEntry->nRelation;
    1766             :                         }
    1767           0 :                         break;
    1768             :                 }
    1769             : 
    1770           0 :                 for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
    1771             :                 {
    1772           0 :                     RelationMap *pEntry = (RelationMap *)rLB.GetEntryData(i);
    1773           0 :                     if (pEntry->nRelation == nRel)
    1774             :                     {
    1775           0 :                         rLB.SelectEntryPos(i);
    1776           0 :                         break;
    1777             :                     }
    1778             :                 }
    1779             : 
    1780           0 :                 if (!rLB.GetSelectEntryCount())
    1781           0 :                     rLB.SelectEntryPos(0);
    1782             :             }
    1783             :         }
    1784             :     }
    1785             : 
    1786           0 :     rLB.Enable(rLB.GetEntryCount() != 0);
    1787           0 :     rFT.Enable(rLB.GetEntryCount() != 0);
    1788             : 
    1789           0 :     RelHdl(&rLB);
    1790             : 
    1791           0 :     return nLBRelations;
    1792             : }
    1793             : 
    1794           0 : sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap *_pMap,
    1795             :                                       sal_uInt16 _nAlign,
    1796             :                                       const sal_uInt16 _nRel,
    1797             :                                       ListBox &_rLB)
    1798             : {
    1799           0 :     OUString sSelEntry, sOldEntry;
    1800           0 :     sOldEntry = _rLB.GetSelectEntry();
    1801             : 
    1802           0 :     _rLB.Clear();
    1803             : 
    1804             :     // #i22341# - determine all possible listbox relations for
    1805             :     // given relation for map <aVCharMap>
    1806             :     const sal_uLong nLBRelations = (_pMap != aVCharMap)
    1807             :                                ? 0L
    1808           0 :                                : ::lcl_GetLBRelationsForRelations( _nRel );
    1809             : 
    1810             :     // fill listbox
    1811           0 :     std::size_t nCount = ::lcl_GetFrmMapCount(_pMap);
    1812           0 :     for (std::size_t i = 0; _pMap && i < nCount; ++i)
    1813             :     {
    1814             : //      #61359# why not from the left/from inside or from the top?
    1815             : //      if (!bFormat || (pMap[i].eStrId != SwFPos::FROMLEFT && pMap[i].eStrId != SwFPos::FROMTOP))
    1816             :         {
    1817           0 :             SvxSwFramePosString::StringId eStrId = m_pHoriMirrorCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
    1818           0 :             eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1819           0 :             OUString sEntry(m_aFramePosString.GetString(eStrId));
    1820           0 :             if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
    1821             :             {
    1822             :                 // don't insert duplicate entries at character wrapped borders
    1823           0 :                 _rLB.InsertEntry(sEntry);
    1824             :             }
    1825             :             // #i22341# - add condition to handle map <aVCharMap>
    1826             :             // that is ambigous in the alignment.
    1827           0 :             if ( _pMap[i].nAlign == _nAlign &&
    1828           0 :                  ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
    1829             :             {
    1830           0 :                 sSelEntry = sEntry;
    1831           0 :             }
    1832             :         }
    1833             :     }
    1834             : 
    1835           0 :     _rLB.SelectEntry(sSelEntry);
    1836           0 :     if (!_rLB.GetSelectEntryCount())
    1837           0 :         _rLB.SelectEntry(sOldEntry);
    1838             : 
    1839           0 :     if (!_rLB.GetSelectEntryCount())
    1840           0 :         _rLB.SelectEntryPos(0);
    1841             : 
    1842           0 :     PosHdl(&_rLB);
    1843             : 
    1844           0 :     return GetMapPos(_pMap, _rLB);
    1845             : }
    1846             : 
    1847           0 : void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView )
    1848             : {
    1849           0 :     m_pSdrView = pSdrView;
    1850           0 :     if(!m_pSdrView)
    1851             :     {
    1852             :         OSL_FAIL("No SdrView* set");
    1853           0 :         return;
    1854             :     }
    1855             : 
    1856             :     // setting of the rectangle and the working area
    1857           0 :     m_aRect = m_pSdrView->GetAllMarkedRect();
    1858           0 :     m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
    1859             : 
    1860             :     // get WorkArea
    1861           0 :     m_aWorkArea = m_pSdrView->GetWorkArea();
    1862             : 
    1863             :     // consider anchor position (for Writer)
    1864           0 :     const SdrMarkList& rMarkList = m_pSdrView->GetMarkedObjectList();
    1865           0 :     if( rMarkList.GetMarkCount() > 0 )
    1866             :     {
    1867           0 :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1868           0 :         m_aAnchorPos = pObj->GetAnchorPos();
    1869             : 
    1870           0 :         if( m_aAnchorPos != Point(0,0) ) // -> Writer
    1871             :         {
    1872           0 :             for( size_t i = 1; i < rMarkList.GetMarkCount(); ++i )
    1873             :             {
    1874           0 :                 pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
    1875           0 :                 if( m_aAnchorPos != pObj->GetAnchorPos() )
    1876             :                 {
    1877             :                     // different anchor positions -> disable positioning
    1878           0 :                     m_pPosFrame->Enable(false);
    1879           0 :                     m_bPositioningDisabled = true;
    1880           0 :                     return;
    1881             :                 }
    1882             :             }
    1883             :         }
    1884           0 :         Point aPt = m_aAnchorPos * -1;
    1885           0 :         Point aPt2 = aPt;
    1886             : 
    1887           0 :         aPt += m_aWorkArea.TopLeft();
    1888           0 :         m_aWorkArea.SetPos( aPt );
    1889             : 
    1890           0 :         aPt2 += m_aRect.TopLeft();
    1891           0 :         m_aRect.SetPos( aPt2 );
    1892             :     }
    1893             : 
    1894             :     // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
    1895           0 :     if( rMarkList.GetMarkCount() != 1 )
    1896           0 :         m_bIsMultiSelection = true;
    1897             : #if OSL_DEBUG_LEVEL > 1
    1898             :     else
    1899             :     {
    1900             :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1901             :         SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
    1902             :         if( ( pObj->GetObjInventor() == SdrInventor ) &&
    1903             :             ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) &&
    1904             :             pObj->HasText() )
    1905             :         {
    1906             :             OSL_FAIL("AutoWidth/AutoHeight should be enabled");
    1907             :         }
    1908             :     }
    1909             : #endif
    1910           0 : }
    1911             : 
    1912             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10