LCOV - code coverage report
Current view: top level - cui/source/tabpages - swpossizetabpage.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 850 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 41 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           0 : SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage()
     592             : {
     593           0 :     disposeOnce();
     594           0 : }
     595             : 
     596           0 : void SvxSwPosSizeTabPage::dispose()
     597             : {
     598           0 :     m_pWidthMF.clear();
     599           0 :     m_pHeightMF.clear();
     600           0 :     m_pKeepRatioCB.clear();
     601           0 :     m_pToPageRB.clear();
     602           0 :     m_pToParaRB.clear();
     603           0 :     m_pToCharRB.clear();
     604           0 :     m_pAsCharRB.clear();
     605           0 :     m_pToFrameRB.clear();
     606           0 :     m_pPositionCB.clear();
     607           0 :     m_pSizeCB.clear();
     608           0 :     m_pPosFrame.clear();
     609           0 :     m_pHoriFT.clear();
     610           0 :     m_pHoriLB.clear();
     611           0 :     m_pHoriByFT.clear();
     612           0 :     m_pHoriByMF.clear();
     613           0 :     m_pHoriToFT.clear();
     614           0 :     m_pHoriToLB.clear();
     615           0 :     m_pHoriMirrorCB.clear();
     616           0 :     m_pVertFT.clear();
     617           0 :     m_pVertLB.clear();
     618           0 :     m_pVertByFT.clear();
     619           0 :     m_pVertByMF.clear();
     620           0 :     m_pVertToFT.clear();
     621           0 :     m_pVertToLB.clear();
     622           0 :     m_pFollowCB.clear();
     623           0 :     m_pExampleWN.clear();
     624           0 :     SfxTabPage::dispose();
     625           0 : }
     626             : 
     627             : 
     628             : namespace
     629             : {
     630             :     struct FrmMaps
     631             :     {
     632             :         FrmMap *pMap;
     633             :         size_t nCount;
     634             :     };
     635             : }
     636             : 
     637           0 : void SvxSwPosSizeTabPage::setOptimalFrmWidth()
     638             : {
     639             :     const FrmMaps aMaps[] = {
     640             :         { aHPageMap, SAL_N_ELEMENTS(aHPageMap) },
     641             :         { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) },
     642             :         { aVPageMap, SAL_N_ELEMENTS(aVPageMap) },
     643             :         { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) },
     644             :         { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) },
     645             :         { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) },
     646             :         { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) },
     647             :         { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFrameMap) },
     648             :         { aHParaMap, SAL_N_ELEMENTS(aHParaMap) },
     649             :         { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) },
     650             :         { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) },
     651             :         { aVParaMap, SAL_N_ELEMENTS(aVParaMap) },
     652             :         { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) },
     653             :         { aHCharMap, SAL_N_ELEMENTS(aHCharMap) },
     654             :         { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) },
     655             :         { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) },
     656             :         { aVCharMap, SAL_N_ELEMENTS(aVCharMap) },
     657             :         { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) },
     658             :         { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) },
     659             :         { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) },
     660             :         { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) }
     661           0 :     };
     662             : 
     663           0 :     std::vector<SvxSwFramePosString::StringId> aFrames;
     664           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     665             :     {
     666           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     667             :         {
     668           0 :             aFrames.push_back(aMaps[i].pMap[j].eStrId);
     669           0 :             aFrames.push_back(aMaps[i].pMap[j].eMirrorStrId);
     670             :         }
     671             :     }
     672             : 
     673           0 :     std::sort(aFrames.begin(), aFrames.end());
     674           0 :     aFrames.erase(std::unique(aFrames.begin(), aFrames.end()), aFrames.end());
     675             : 
     676           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aFrames.begin(), aEnd = aFrames.end();
     677             :         aI != aEnd; ++aI)
     678             :     {
     679           0 :         m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
     680             :     }
     681             : 
     682           0 :     Size aBiggest(m_pHoriLB->GetOptimalSize());
     683           0 :     m_pHoriLB->set_width_request(aBiggest.Width());
     684           0 :     m_pVertLB->set_width_request(aBiggest.Width());
     685           0 :     m_pHoriLB->Clear();
     686           0 : }
     687             : 
     688             : namespace
     689             : {
     690             :     struct RelationMaps
     691             :     {
     692             :         RelationMap *pMap;
     693             :         size_t nCount;
     694             :     };
     695             : }
     696             : 
     697           0 : void SvxSwPosSizeTabPage::setOptimalRelWidth()
     698             : {
     699             :     const RelationMaps aMaps[] = {
     700             :         { aRelationMap, SAL_N_ELEMENTS(aRelationMap) },
     701             :         { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) }
     702           0 :     };
     703             : 
     704           0 :     std::vector<SvxSwFramePosString::StringId> aRels;
     705           0 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aMaps); ++i)
     706             :     {
     707           0 :         for (size_t j = 0; j < aMaps[i].nCount; ++j)
     708             :         {
     709           0 :             aRels.push_back(aMaps[i].pMap[j].eStrId);
     710           0 :             aRels.push_back(aMaps[i].pMap[j].eMirrorStrId);
     711             :         }
     712             :     }
     713             : 
     714           0 :     std::sort(aRels.begin(), aRels.end());
     715           0 :     aRels.erase(std::unique(aRels.begin(), aRels.end()), aRels.end());
     716             : 
     717           0 :     for (std::vector<SvxSwFramePosString::StringId>::const_iterator aI = aRels.begin(), aEnd = aRels.end();
     718             :         aI != aEnd; ++aI)
     719             :     {
     720           0 :         m_pHoriLB->InsertEntry(m_aFramePosString.GetString(*aI));
     721             :     }
     722             : 
     723           0 :     Size aBiggest(m_pHoriLB->GetOptimalSize());
     724           0 :     m_pHoriLB->set_width_request(aBiggest.Width());
     725           0 :     m_pVertLB->set_width_request(aBiggest.Width());
     726           0 :     m_pHoriLB->Clear();
     727           0 : }
     728             : 
     729           0 : VclPtr<SfxTabPage> SvxSwPosSizeTabPage::Create( vcl::Window* pParent, const SfxItemSet* rSet)
     730             : {
     731           0 :     return VclPtr<SvxSwPosSizeTabPage>::Create(pParent, *rSet);
     732             : }
     733             : 
     734           0 : const sal_uInt16* SvxSwPosSizeTabPage::GetRanges()
     735             : {
     736             :     static const sal_uInt16 pSwPosRanges[] =
     737             :     {
     738             :         SID_ATTR_TRANSFORM_POS_X,
     739             :         SID_ATTR_TRANSFORM_POS_Y,
     740             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     741             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     742             :         SID_ATTR_TRANSFORM_INTERN,
     743             :         SID_ATTR_TRANSFORM_INTERN,
     744             :         SID_ATTR_TRANSFORM_ANCHOR,
     745             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     746             :         SID_ATTR_TRANSFORM_WIDTH,
     747             :         SID_ATTR_TRANSFORM_SIZE_POINT,
     748             :         SID_ATTR_TRANSFORM_PROTECT_POS,
     749             :         SID_ATTR_TRANSFORM_INTERN,
     750             :         SID_ATTR_TRANSFORM_AUTOWIDTH,
     751             :         SID_ATTR_TRANSFORM_VERT_ORIENT,
     752             :         SID_HTML_MODE,
     753             :         SID_HTML_MODE,
     754             :         SID_SW_FOLLOW_TEXT_FLOW,
     755             :         SID_SW_FOLLOW_TEXT_FLOW,
     756             :         SID_ATTR_TRANSFORM_HORI_POSITION,
     757             :         SID_ATTR_TRANSFORM_VERT_POSITION,
     758             :         0
     759             :     };
     760           0 :     return pSwPosRanges;
     761             : }
     762             : 
     763           0 : bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet)
     764             : {
     765           0 :     bool bAnchorChanged = false;
     766           0 :     short nAnchor = GetAnchorType(&bAnchorChanged);
     767           0 :     bool bModified = false;
     768           0 :     if(bAnchorChanged)
     769             :     {
     770           0 :         rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
     771           0 :         bModified = true;
     772             :     }
     773           0 :     if ( m_pPositionCB->IsValueChangedFromSaved() )
     774             :     {
     775           0 :         if( m_pPositionCB->GetState() == TRISTATE_INDET )
     776           0 :             rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
     777             :         else
     778             :             rSet->Put(
     779           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
     780           0 :                 m_pPositionCB->GetState() == TRISTATE_TRUE ) );
     781           0 :         bModified = true;
     782             :     }
     783             : 
     784           0 :     if ( m_pSizeCB->IsValueChangedFromSaved() )
     785             :     {
     786           0 :         if ( m_pSizeCB->GetState() == TRISTATE_INDET )
     787           0 :             rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
     788             :         else
     789             :             rSet->Put(
     790           0 :                 SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
     791           0 :                 m_pSizeCB->GetState() == TRISTATE_TRUE ) );
     792           0 :         bModified = true;
     793             :     }
     794             : 
     795           0 :     const SfxItemSet& rOldSet = GetItemSet();
     796             : 
     797           0 :     if(!m_bPositioningDisabled)
     798             :     {
     799             :         //on multiple selections the positioning is set via SdrView
     800           0 :         if(m_bIsMultiSelection)
     801             :         {
     802           0 :             if( m_pHoriByMF->IsValueModified() || m_pVertByMF->IsValueModified() )
     803             :             {
     804             :                 long nHoriByPos =
     805           0 :                             static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
     806             :                 long nVertByPos =
     807           0 :                             static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
     808             : 
     809             :                 // old rectangle with CoreUnit
     810           0 :                 m_aRect = m_pSdrView->GetAllMarkedRect();
     811           0 :                 m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
     812             : 
     813           0 :                 nHoriByPos += m_aAnchorPos.X();
     814           0 :                 nVertByPos += m_aAnchorPos.Y();
     815             : 
     816           0 :                 rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) );
     817           0 :                 rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) );
     818             : 
     819           0 :                 bModified = true;
     820             :             }
     821             :         }
     822             :         else
     823             :         {
     824           0 :             if ( m_pHMap )
     825             :             {
     826             :                 const SfxInt16Item& rHoriOrient =
     827           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT));
     828             :                 const SfxInt16Item& rHoriRelation =
     829           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION));
     830             :                 const SfxInt32Item& rHoriPosition =
     831           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ;
     832             : 
     833           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
     834           0 :                 short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
     835           0 :                 short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
     836             :                 const long nHoriByPos =
     837           0 :                             static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
     838           0 :                 if (
     839           0 :                     nAlign != rHoriOrient.GetValue() ||
     840           0 :                     nRel != rHoriRelation.GetValue() ||
     841           0 :                     (m_pHoriByMF->IsEnabled() && nHoriByPos != rHoriPosition.GetValue())
     842             :                    )
     843             :                 {
     844           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign));
     845           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel));
     846           0 :                     if(m_pHoriByMF->IsEnabled())
     847           0 :                         rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos));
     848           0 :                     bModified = true;
     849             :                 }
     850             :             }
     851           0 :             if(m_pHoriMirrorCB->IsEnabled() && m_pHoriMirrorCB->IsValueChangedFromSaved())
     852           0 :                 bModified |= 0 != rSet->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_pHoriMirrorCB->IsChecked()));
     853             : 
     854           0 :             if ( m_pVMap )
     855             :             {
     856             :                 const SfxInt16Item& rVertOrient =
     857           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT));
     858             :                 const SfxInt16Item& rVertRelation =
     859           0 :                         static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION));
     860             :                 const SfxInt32Item& rVertPosition =
     861           0 :                         static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION));
     862             : 
     863           0 :                 sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
     864           0 :                 short nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
     865           0 :                 short nRel = GetRelation(m_pVMap, *m_pVertToLB);
     866             :                 // #i34055# - convert vertical position for
     867             :                 // as-character anchored objects
     868             :                 long nVertByPos =
     869           0 :                         static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
     870           0 :                 if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER )
     871             :                 {
     872           0 :                     nVertByPos *= -1;
     873             :                 }
     874           0 :                 if ( nAlign != rVertOrient.GetValue() ||
     875           0 :                      nRel != rVertRelation.GetValue() ||
     876           0 :                      ( m_pVertByMF->IsEnabled() &&
     877           0 :                        nVertByPos != rVertPosition.GetValue() ) )
     878             :                 {
     879           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign));
     880           0 :                     rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel));
     881           0 :                     if(m_pVertByMF->IsEnabled())
     882           0 :                         rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos));
     883           0 :                     bModified = true;
     884             :                 }
     885             :             }
     886             : 
     887             :             // #i18732#
     888           0 :             if(m_pFollowCB->IsValueChangedFromSaved())
     889             :             {
     890             :                 //Writer internal type - based on SfxBoolItem
     891           0 :                 const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW);
     892           0 :                 if(pItem)
     893             :                 {
     894           0 :                     boost::scoped_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone()));
     895           0 :                     pFollow->SetValue(m_pFollowCB->IsChecked());
     896           0 :                     bModified |= 0 != rSet->Put(*pFollow);
     897             :                 }
     898             :             }
     899             :         }
     900             :     }
     901           0 :     if ( m_pWidthMF->IsValueModified() || m_pHeightMF->IsValueModified() )
     902             :     {
     903           0 :         sal_uInt32 nWidth = static_cast<sal_uInt32>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
     904           0 :         sal_uInt32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
     905           0 :         rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ),
     906           0 :                         (sal_uInt32) nWidth ) );
     907           0 :         rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ),
     908           0 :                         (sal_uInt32) nHeight ) );
     909             :         //this item is required by SdrEditView::SetGeoAttrToMarked()
     910           0 :         rSet->Put( SfxAllEnumItem( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), RP_LT ) );
     911             : 
     912           0 :         bModified = true;
     913             :     }
     914             : 
     915           0 :     return bModified;
     916             : }
     917             : 
     918           0 : void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet)
     919             : {
     920           0 :     const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_ANCHOR );
     921           0 :     bool bInvalidateAnchor = false;
     922           0 :     short nAnchorType = TextContentAnchorType_AT_PARAGRAPH;
     923           0 :     if(pItem)
     924             :     {
     925           0 :         nAnchorType = static_cast<const SfxInt16Item*>(pItem)->GetValue();
     926           0 :         switch(nAnchorType)
     927             :         {
     928           0 :             case  TextContentAnchorType_AT_PAGE:        m_pToPageRB->Check();  break;
     929           0 :             case  TextContentAnchorType_AT_PARAGRAPH:   m_pToParaRB->Check();  break;
     930           0 :             case  TextContentAnchorType_AT_CHARACTER:   m_pToCharRB->Check();  break;
     931           0 :             case  TextContentAnchorType_AS_CHARACTER:   m_pAsCharRB->Check();  break;
     932           0 :             case  TextContentAnchorType_AT_FRAME:       m_pToFrameRB->Check(); break;
     933           0 :             default : bInvalidateAnchor = true;
     934             :         }
     935           0 :         m_pToPageRB->SaveValue();
     936           0 :         m_pToParaRB->SaveValue();
     937           0 :         m_pToCharRB->SaveValue();
     938           0 :         m_pAsCharRB->SaveValue();
     939           0 :         m_pToFrameRB->SaveValue();
     940             :     }
     941           0 :     if(bInvalidateAnchor)
     942             :     {
     943           0 :         m_pToPageRB->Enable( false );
     944           0 :         m_pToParaRB->Enable( false );
     945           0 :         m_pToCharRB->Enable( false );
     946           0 :         m_pAsCharRB->Enable( false );
     947           0 :         m_pToFrameRB->Enable( false );
     948             :     }
     949             : 
     950           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS );
     951           0 :     if ( pItem )
     952             :     {
     953           0 :         bool bProtected = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     954           0 :         m_pPositionCB->SetState( bProtected ? TRISTATE_TRUE : TRISTATE_FALSE );
     955           0 :         m_pPositionCB->EnableTriState( false );
     956           0 :         m_pSizeCB->Enable( !bProtected );
     957             :     }
     958             :     else
     959             :     {
     960           0 :         m_pPositionCB->SetState( TRISTATE_INDET );
     961             :     }
     962             : 
     963           0 :     m_pPositionCB->SaveValue();
     964             : 
     965           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE );
     966             : 
     967           0 :     if ( pItem )
     968             :     {
     969           0 :         m_pSizeCB->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue()
     970           0 :                               ? TRISTATE_TRUE : TRISTATE_FALSE );
     971           0 :         m_pSizeCB->EnableTriState( false );
     972             :     }
     973             :     else
     974           0 :         m_pSizeCB->SetState( TRISTATE_INDET );
     975           0 :     m_pSizeCB->SaveValue();
     976             : 
     977           0 :     pItem = GetItem( *rSet, SID_HTML_MODE );
     978           0 :     if(pItem)
     979             :     {
     980             :         m_bHtmlMode =
     981           0 :             (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
     982           0 :             != 0;
     983             :     }
     984             : 
     985           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT );
     986           0 :     if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue())
     987             :     {
     988           0 :         OUString sHLabel = m_pHoriFT->GetText();
     989           0 :         m_pHoriFT->SetText(m_pVertFT->GetText());
     990           0 :         m_pVertFT->SetText(sHLabel);
     991           0 :         m_bIsVerticalFrame = true;
     992             :     }
     993           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT);
     994           0 :     if(pItem)
     995           0 :         m_bIsInRightToLeft = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     996             : 
     997           0 :     pItem = GetItem( *rSet, SID_SW_FOLLOW_TEXT_FLOW);
     998           0 :     if(pItem)
     999             :     {
    1000             :         const bool bFollowTextFlow =
    1001           0 :             static_cast<const SfxBoolItem*>(pItem)->GetValue();
    1002           0 :         m_pFollowCB->Check( bFollowTextFlow );
    1003             :     }
    1004           0 :     m_pFollowCB->SaveValue();
    1005             : 
    1006           0 :     if(m_bHtmlMode)
    1007             :     {
    1008           0 :         m_pHoriMirrorCB->Show(false);
    1009           0 :         m_pKeepRatioCB->Enable(false);
    1010             :         // #i18732# - hide checkbox in HTML mode
    1011           0 :         m_pFollowCB->Show(false);
    1012             :     }
    1013             :     else
    1014             :     {
    1015             :         // #i18732# correct enable/disable of check box 'Mirror on..'
    1016           0 :         m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
    1017             : 
    1018             :         // #i18732# - enable/disable check box 'Follow text flow'.
    1019           0 :         m_pFollowCB->Enable( m_pToParaRB->IsChecked() ||
    1020           0 :                                   m_pToCharRB->IsChecked() );
    1021             :     }
    1022             : 
    1023           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_WIDTH );
    1024           0 :     sal_Int32 nWidth = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
    1025             : 
    1026           0 :     m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
    1027             : 
    1028           0 :     pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HEIGHT );
    1029           0 :     sal_Int32 nHeight = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, (sal_uInt32)1 );
    1030           0 :     m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
    1031           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    1032             : 
    1033           0 :     if(!m_bPositioningDisabled)
    1034             :     {
    1035           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_ORIENT);
    1036           0 :         if(pItem)
    1037             :         {
    1038           0 :             short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1039           0 :             m_nOldH = nHoriOrientation;
    1040             :         }
    1041           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_ORIENT);
    1042           0 :         if(pItem)
    1043             :         {
    1044           0 :             short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1045           0 :             m_nOldV = nVertOrientation;
    1046             :         }
    1047           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_RELATION);
    1048           0 :         if(pItem)
    1049             :         {
    1050           0 :             m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1051             :         }
    1052             : 
    1053           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_RELATION);
    1054           0 :         if(pItem)
    1055             :         {
    1056           0 :             m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue();
    1057             :         }
    1058           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR);
    1059           0 :         if(pItem)
    1060           0 :             m_pHoriMirrorCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
    1061           0 :         m_pHoriMirrorCB->SaveValue();
    1062             : 
    1063           0 :         sal_Int32 nHoriPos = 0;
    1064           0 :         sal_Int32 nVertPos = 0;
    1065           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_POSITION);
    1066           0 :         if(pItem)
    1067           0 :             nHoriPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
    1068           0 :         pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_POSITION);
    1069           0 :         if(pItem)
    1070           0 :             nVertPos = static_cast<const SfxInt32Item*>(pItem)->GetValue();
    1071             : 
    1072           0 :         InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos);
    1073             : 
    1074           0 :         m_pVertByMF->SaveValue();
    1075           0 :         m_pHoriByMF->SaveValue();
    1076             :         // #i18732#
    1077           0 :         m_pFollowCB->SaveValue();
    1078             : 
    1079           0 :         RangeModifyHdl(m_pWidthMF);  // initially set maximum values
    1080             :     }
    1081           0 : }
    1082             : 
    1083           0 : SfxTabPage::sfxpg SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
    1084             : {
    1085           0 :     if( _pSet )
    1086           0 :         FillItemSet( _pSet );
    1087           0 :     return LEAVE_PAGE;
    1088             : }
    1089             : 
    1090           0 : void SvxSwPosSizeTabPage::EnableAnchorTypes(sal_uInt16 nAnchorEnable)
    1091             : {
    1092           0 :     if((nAnchorEnable & SVX_OBJ_AT_FLY))
    1093           0 :         m_pToFrameRB->Show();
    1094           0 :     if(!(nAnchorEnable & SVX_OBJ_PAGE))
    1095           0 :         m_pToPageRB->Enable(false);
    1096           0 : }
    1097             : 
    1098           0 : short SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged)
    1099             : {
    1100           0 :     short nRet = -1;
    1101           0 :     RadioButton* pCheckedButton = 0;
    1102           0 :     if(m_pToParaRB->IsEnabled())
    1103             :     {
    1104           0 :         if(m_pToPageRB->IsChecked())
    1105             :         {
    1106           0 :             nRet = TextContentAnchorType_AT_PAGE;
    1107           0 :             pCheckedButton = m_pToPageRB;
    1108             :         }
    1109           0 :         else if(m_pToParaRB->IsChecked())
    1110             :         {
    1111           0 :             nRet = TextContentAnchorType_AT_PARAGRAPH;
    1112           0 :             pCheckedButton = m_pToParaRB;
    1113             :         }
    1114           0 :         else if(m_pToCharRB->IsChecked())
    1115             :         {
    1116           0 :             nRet = TextContentAnchorType_AT_CHARACTER;
    1117           0 :             pCheckedButton = m_pToCharRB;
    1118             :         }
    1119           0 :         else if(m_pAsCharRB->IsChecked())
    1120             :         {
    1121           0 :             nRet = TextContentAnchorType_AS_CHARACTER;
    1122           0 :             pCheckedButton = m_pAsCharRB;
    1123             :         }
    1124           0 :         else if(m_pToFrameRB->IsChecked())
    1125             :         {
    1126           0 :             nRet = TextContentAnchorType_AT_FRAME;
    1127           0 :             pCheckedButton = m_pToFrameRB;
    1128             :         }
    1129             :     }
    1130           0 :     if(pbHasChanged)
    1131             :     {
    1132           0 :          if(pCheckedButton)
    1133           0 :              *pbHasChanged = pCheckedButton->IsValueChangedFromSaved();
    1134             :          else
    1135           0 :              *pbHasChanged = false;
    1136             :     }
    1137           0 :    return nRet;
    1138             : }
    1139             : 
    1140           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl)
    1141             : {
    1142           0 :     if(m_bPositioningDisabled)
    1143           0 :         return 0;
    1144           0 :     SvxSwFrameValidation        aVal;
    1145             : 
    1146           0 :     aVal.nAnchorType = GetAnchorType();
    1147           0 :     aVal.bAutoHeight = false;
    1148           0 :     aVal.bAutoWidth = false;
    1149           0 :     aVal.bMirror = m_pHoriMirrorCB->IsChecked();
    1150             :     // #i18732#
    1151           0 :     aVal.bFollowTextFlow = m_pFollowCB->IsChecked();
    1152             : 
    1153           0 :     if ( m_pHMap )
    1154             :     {
    1155             :         // horizontal alignment
    1156           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriToLB);
    1157           0 :         sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
    1158           0 :         sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1159             : 
    1160           0 :         aVal.nHoriOrient = (short)nAlign;
    1161           0 :         aVal.nHRelOrient = (short)nRel;
    1162             :     }
    1163             :     else
    1164           0 :         aVal.nHoriOrient = HoriOrientation::NONE;
    1165             : 
    1166           0 :     if ( m_pVMap )
    1167             :     {
    1168             :         // vertical alignment
    1169           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
    1170           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
    1171           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
    1172             : 
    1173           0 :         aVal.nVertOrient = (short)nAlign;
    1174           0 :         aVal.nVRelOrient = (short)nRel;
    1175             :     }
    1176             :     else
    1177           0 :         aVal.nVertOrient = VertOrientation::NONE;
    1178             : 
    1179             :     const long nAtHorzPosVal =
    1180           0 :                     static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
    1181             :     const long nAtVertPosVal =
    1182           0 :                     static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
    1183             : 
    1184           0 :     aVal.nHPos = nAtHorzPosVal;
    1185           0 :     aVal.nVPos = nAtVertPosVal;
    1186             : 
    1187           0 :     sal_Int32 nWidth = static_cast<sal_uInt32>(m_pWidthMF-> Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)));
    1188           0 :     sal_Int32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)));
    1189           0 :     aVal.nWidth  = nWidth;
    1190           0 :     aVal.nHeight = nHeight;
    1191             : 
    1192           0 :     if(m_aValidateLink.IsSet())
    1193           0 :         m_aValidateLink.Call(&aVal);
    1194             : 
    1195           0 :     nWidth = aVal.nWidth;
    1196           0 :     nHeight = aVal.nHeight;
    1197             : 
    1198             :     // minimum width also for style
    1199           0 :     m_pHeightMF->SetMin(m_pHeightMF->Normalize(aVal.nMinHeight), FUNIT_TWIP);
    1200           0 :     m_pWidthMF-> SetMin(m_pWidthMF->Normalize(aVal.nMinWidth), FUNIT_TWIP);
    1201             : 
    1202           0 :     sal_Int32 nMaxWidth(aVal.nMaxWidth);
    1203           0 :     sal_Int32 nMaxHeight(aVal.nMaxHeight);
    1204             : 
    1205           0 :     sal_Int64 nTmp = m_pHeightMF->Normalize(nMaxHeight);
    1206           0 :     m_pHeightMF->SetMax(nTmp, FUNIT_TWIP);
    1207             : 
    1208           0 :     nTmp = m_pWidthMF->Normalize(nMaxWidth);
    1209           0 :     m_pWidthMF->SetMax(nTmp, FUNIT_TWIP);
    1210             : 
    1211           0 :     m_pHoriByMF->SetMin(m_pHoriByMF->Normalize(aVal.nMinHPos), FUNIT_TWIP);
    1212           0 :     m_pHoriByMF->SetMax(m_pHoriByMF->Normalize(aVal.nMaxHPos), FUNIT_TWIP);
    1213           0 :     if ( aVal.nHPos != nAtHorzPosVal )
    1214           0 :         m_pHoriByMF->SetValue(m_pHoriByMF->Normalize(aVal.nHPos), FUNIT_TWIP);
    1215             : 
    1216           0 :     m_pVertByMF->SetMin(m_pVertByMF->Normalize(aVal.nMinVPos ), FUNIT_TWIP);
    1217           0 :     m_pVertByMF->SetMax(m_pVertByMF->Normalize(aVal.nMaxVPos), FUNIT_TWIP);
    1218           0 :     if ( aVal.nVPos != nAtVertPosVal )
    1219           0 :         m_pVertByMF->SetValue(m_pVertByMF->Normalize(aVal.nVPos), FUNIT_TWIP);
    1220             : 
    1221           0 :     return 0;
    1222             : }
    1223             : 
    1224           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl)
    1225             : {
    1226           0 :     m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection);
    1227             : 
    1228             :     // #i18732# - enable check box 'Follow text flow' for anchor
    1229             :     // type to-paragraph' and to-character
    1230           0 :     m_pFollowCB->Enable( m_pToParaRB->IsChecked() || m_pToCharRB->IsChecked() );
    1231             : 
    1232           0 :     short nId = GetAnchorType();
    1233             : 
    1234           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1235           0 :     RangeModifyHdl(0);
    1236             : 
    1237           0 :     if(m_bHtmlMode)
    1238             :     {
    1239           0 :         PosHdl(m_pHoriLB);
    1240           0 :         PosHdl(m_pVertLB);
    1241             :     }
    1242           0 :     return 0;
    1243             : }
    1244             : 
    1245           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl)
    1246             : {
    1247           0 :     short nId = GetAnchorType();
    1248           0 :     InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX);
    1249             : 
    1250           0 :     return 0;
    1251             : }
    1252             : 
    1253           0 : IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox *, pLB )
    1254             : {
    1255           0 :     bool bHori = pLB == m_pHoriToLB;
    1256             : 
    1257           0 :     UpdateExample();
    1258             : 
    1259           0 :     if (bHori)
    1260           0 :         m_bAtHoriPosModified = true;
    1261             :     else
    1262           0 :         m_bAtVertPosModified = true;
    1263             : 
    1264           0 :     if(m_bHtmlMode  && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) // again special treatment
    1265             :     {
    1266           0 :         if(bHori)
    1267             :         {
    1268           0 :             sal_uInt16 nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1269           0 :             if(RelOrientation::PRINT_AREA == nRel && 0 == m_pVertLB->GetSelectEntryPos())
    1270             :             {
    1271           0 :                 m_pVertLB->SelectEntryPos(1);
    1272             :             }
    1273           0 :             else if(RelOrientation::CHAR == nRel && 1 == m_pVertLB->GetSelectEntryPos())
    1274             :             {
    1275           0 :                 m_pVertLB->SelectEntryPos(0);
    1276             :             }
    1277             :         }
    1278             :     }
    1279           0 :     if (pLB)    // only if the hanlder has been called by a change of the controller
    1280           0 :         RangeModifyHdl(0);
    1281             : 
    1282           0 :     return 0;
    1283             : 
    1284             : }
    1285             : 
    1286           0 : IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox *, pLB )
    1287             : {
    1288           0 :     bool bHori = pLB == m_pHoriLB;
    1289           0 :     ListBox *pRelLB = bHori ? m_pHoriToLB : m_pVertToLB;
    1290           0 :     FixedText *pRelFT = bHori ? m_pHoriToFT : m_pVertToFT;
    1291           0 :     FrmMap *pMap = bHori ? m_pHMap : m_pVMap;
    1292             : 
    1293             : 
    1294           0 :     sal_uInt16 nMapPos = GetMapPos(pMap, *pLB);
    1295           0 :     sal_uInt16 nAlign = GetAlignment(pMap, nMapPos, *pLB, *pRelLB);
    1296             : 
    1297           0 :     if (bHori)
    1298             :     {
    1299           0 :         bool bEnable = HoriOrientation::NONE == nAlign;
    1300           0 :         m_pHoriByMF->Enable( bEnable );
    1301           0 :         m_pHoriByFT->Enable( bEnable );
    1302             :     }
    1303             :     else
    1304             :     {
    1305           0 :         bool bEnable = VertOrientation::NONE == nAlign;
    1306           0 :         m_pVertByMF->Enable( bEnable );
    1307           0 :         m_pVertByFT->Enable( bEnable );
    1308             :     }
    1309             : 
    1310           0 :     RangeModifyHdl( 0 );
    1311             : 
    1312           0 :     short nRel = 0;
    1313           0 :     if (pLB->GetSelectEntryCount())
    1314             :     {
    1315             : 
    1316           0 :         if (pRelLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1317           0 :             nRel = static_cast<RelationMap *>(pRelLB->GetSelectEntryData())->nRelation;
    1318             : 
    1319           0 :         FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT);
    1320             :     }
    1321             :     else
    1322           0 :         pRelLB->Clear();
    1323             : 
    1324           0 :     UpdateExample();
    1325             : 
    1326           0 :     if (bHori)
    1327           0 :         m_bAtHoriPosModified = true;
    1328             :     else
    1329           0 :         m_bAtVertPosModified = true;
    1330             : 
    1331             :     // special treatment for HTML-Mode with horz-vert-dependencies
    1332           0 :     if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType())
    1333             :     {
    1334           0 :         bool bSet = false;
    1335           0 :         if(bHori)
    1336             :         {
    1337             :             // on the right only below is allowed - from the left only at the top
    1338             :             // from the left at the character -> below
    1339           0 :             if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) &&
    1340           0 :                     0 == m_pVertLB->GetSelectEntryPos())
    1341             :             {
    1342           0 :                 if(RelOrientation::FRAME == nRel)
    1343           0 :                     m_pVertLB->SelectEntryPos(1);
    1344             :                 else
    1345           0 :                     m_pVertLB->SelectEntryPos(0);
    1346           0 :                 bSet = true;
    1347             :             }
    1348           0 :             else if(HoriOrientation::LEFT == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
    1349             :             {
    1350           0 :                 m_pVertLB->SelectEntryPos(0);
    1351           0 :                 bSet = true;
    1352             :             }
    1353           0 :             else if(HoriOrientation::NONE == nAlign && 1 == m_pVertLB->GetSelectEntryPos())
    1354             :             {
    1355           0 :                 m_pVertLB->SelectEntryPos(0);
    1356           0 :                 bSet = true;
    1357             :             }
    1358           0 :             if(bSet)
    1359           0 :                 PosHdl(m_pVertLB);
    1360             :         }
    1361             :         else
    1362             :         {
    1363           0 :             if(VertOrientation::TOP == nAlign)
    1364             :             {
    1365           0 :                 if(1 == m_pHoriLB->GetSelectEntryPos())
    1366             :                 {
    1367           0 :                     m_pHoriLB->SelectEntryPos(0);
    1368           0 :                     bSet = true;
    1369             :                 }
    1370           0 :                 m_pHoriToLB->SelectEntryPos(1);
    1371             :             }
    1372           0 :             else if(VertOrientation::CHAR_BOTTOM == nAlign)
    1373             :             {
    1374           0 :                 if(2 == m_pHoriLB->GetSelectEntryPos())
    1375             :                 {
    1376           0 :                     m_pHoriLB->SelectEntryPos(0);
    1377           0 :                     bSet = true;
    1378             :                 }
    1379           0 :                 m_pHoriToLB->SelectEntryPos(0) ;
    1380             :             }
    1381           0 :             if(bSet)
    1382           0 :                 PosHdl(m_pHoriLB);
    1383             :         }
    1384             : 
    1385             :     }
    1386           0 :     return 0;
    1387             : }
    1388             : 
    1389           0 : IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, Edit *, pEdit )
    1390             : {
    1391           0 :     sal_Int64 nWidth = m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP));
    1392           0 :     sal_Int64 nHeight = m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP));
    1393           0 :     if ( m_pKeepRatioCB->IsChecked() )
    1394             :     {
    1395           0 :         if ( pEdit == m_pWidthMF )
    1396             :         {
    1397           0 :             nHeight = sal_Int64((double)nWidth / m_fWidthHeightRatio);
    1398           0 :             m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP);
    1399             :         }
    1400           0 :         else if(pEdit == m_pHeightMF)
    1401             :         {
    1402           0 :             nWidth = sal_Int64((double)nHeight * m_fWidthHeightRatio);
    1403           0 :             m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP);
    1404             :         }
    1405             :     }
    1406           0 :     m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0;
    1407           0 :     UpdateExample();
    1408           0 :     return 0;
    1409             : }
    1410             : 
    1411           0 : IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl)
    1412             : {
    1413           0 :     m_pSizeCB->Enable(m_pPositionCB->IsEnabled() && !m_pPositionCB->IsChecked());
    1414           0 :     return 0;
    1415             : }
    1416             : 
    1417           0 : short SvxSwPosSizeTabPage::GetRelation(FrmMap *, ListBox &rRelationLB)
    1418             : {
    1419           0 :     short nRel = 0;
    1420           0 :     sal_Int32 nPos = rRelationLB.GetSelectEntryPos();
    1421             : 
    1422           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1423             :     {
    1424           0 :         RelationMap *pEntry = static_cast<RelationMap *>(rRelationLB.GetEntryData(nPos));
    1425           0 :         nRel = pEntry->nRelation;
    1426             :     }
    1427             : 
    1428           0 :     return nRel;
    1429             : }
    1430             : 
    1431           0 : short SvxSwPosSizeTabPage::GetAlignment(FrmMap *pMap, sal_uInt16 nMapPos, ListBox &/*rAlignLB*/, ListBox &rRelationLB)
    1432             : {
    1433           0 :     short nAlign = 0;
    1434             : 
    1435             :     // #i22341# - special handling also for map <aVCharMap>,
    1436             :     // because it contains ambigous items for alignment
    1437           0 :     if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap ||
    1438             :             pMap == aVCharMap )
    1439             :     {
    1440           0 :         if (rRelationLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
    1441             :         {
    1442           0 :             sal_uLong  nRel = static_cast<RelationMap *>(rRelationLB.GetSelectEntryData())->nLBRelation;
    1443           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1444           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1445             : 
    1446           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1447             :             {
    1448           0 :                 if (pMap[i].eStrId == eStrId)
    1449             :                 {
    1450           0 :                     sal_uLong nLBRelations = pMap[i].nLBRelations;
    1451           0 :                     if (nLBRelations & nRel)
    1452             :                     {
    1453           0 :                         nAlign = pMap[i].nAlign;
    1454           0 :                         break;
    1455             :                     }
    1456             :                 }
    1457             :             }
    1458           0 :         }
    1459             :     }
    1460           0 :     else if (pMap)
    1461           0 :         nAlign = pMap[nMapPos].nAlign;
    1462             : 
    1463           0 :     return nAlign;
    1464             : }
    1465             : 
    1466           0 : sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap *pMap, ListBox &rAlignLB)
    1467             : {
    1468           0 :     sal_uInt16 nMapPos = 0;
    1469           0 :     sal_Int32 nLBSelPos = rAlignLB.GetSelectEntryPos();
    1470             : 
    1471           0 :     if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND)
    1472             :     {
    1473           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1474             :         {
    1475           0 :             std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1476           0 :             OUString sSelEntry(rAlignLB.GetSelectEntry());
    1477             : 
    1478           0 :             for (std::size_t i = 0; i < nMapCount; i++)
    1479             :             {
    1480           0 :                 SvxSwFramePosString::StringId eResId = pMap[i].eStrId;
    1481             : 
    1482           0 :                 OUString sEntry = m_aFramePosString.GetString(eResId);
    1483             : 
    1484           0 :                 if (sEntry == sSelEntry)
    1485             :                 {
    1486           0 :                     nMapPos = sal::static_int_cast< sal_uInt16 >(i);
    1487           0 :                     break;
    1488             :                 }
    1489           0 :             }
    1490             :         }
    1491             :         else
    1492           0 :             nMapPos = nLBSelPos;
    1493             :     }
    1494             : 
    1495           0 :     return nMapPos;
    1496             : }
    1497             : 
    1498           0 : void SvxSwPosSizeTabPage::InitPos(short nAnchor,
    1499             :                                 sal_uInt16 nH,
    1500             :                                 sal_uInt16 nHRel,
    1501             :                                 sal_uInt16 nV,
    1502             :                                 sal_uInt16 nVRel,
    1503             :                                 long   nX,
    1504             :                                 long   nY)
    1505             : {
    1506           0 :     sal_Int32 nPos = m_pVertLB->GetSelectEntryPos();
    1507           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pVMap )
    1508             :     {
    1509           0 :         m_nOldV    = m_pVMap[nPos].nAlign;
    1510           0 :         nPos = m_pVertToLB->GetSelectEntryPos();
    1511           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1512           0 :             m_nOldVRel = static_cast<RelationMap *>(m_pVertToLB->GetEntryData(nPos))->nRelation;
    1513             :     }
    1514             : 
    1515           0 :     nPos = m_pHoriLB->GetSelectEntryPos();
    1516           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pHMap )
    1517             :     {
    1518           0 :         m_nOldH    = m_pHMap[nPos].nAlign;
    1519             : 
    1520           0 :         nPos = m_pHoriToLB->GetSelectEntryPos();
    1521           0 :         if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1522           0 :             m_nOldHRel = static_cast<RelationMap *>(m_pHoriToLB->GetEntryData(nPos))->nRelation;
    1523             :     }
    1524             : 
    1525           0 :     bool bEnable = true;
    1526           0 :     if( m_bIsMultiSelection )
    1527             :     {
    1528           0 :         m_pVMap = aVMultiSelectionMap;
    1529           0 :         m_pHMap = aHMultiSelectionMap;
    1530             :     }
    1531           0 :     else if( nAnchor == TextContentAnchorType_AT_PAGE )
    1532             :     {
    1533           0 :         m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap;
    1534           0 :         m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap;
    1535             :     }
    1536           0 :     else if ( nAnchor == TextContentAnchorType_AT_FRAME )
    1537             :     {
    1538             :         // #i18732# - own vertical alignment map for to frame
    1539             :         // anchored objects.
    1540           0 :         m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap;
    1541           0 :         m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap;
    1542             :     }
    1543           0 :     else if ( nAnchor == TextContentAnchorType_AT_PARAGRAPH )
    1544             :     {
    1545           0 :         if(m_bHtmlMode)
    1546             :         {
    1547           0 :             m_pVMap = aVParaHtmlMap;
    1548           0 :             m_pHMap = aHParaHtmlAbsMap;
    1549             :         }
    1550             :         else
    1551             :         {
    1552           0 :             m_pVMap = aVParaMap;
    1553           0 :             m_pHMap = aHParaMap;
    1554             :         }
    1555             :     }
    1556           0 :     else if ( nAnchor == TextContentAnchorType_AT_CHARACTER )
    1557             :     {
    1558           0 :         if(m_bHtmlMode)
    1559             :         {
    1560           0 :             m_pVMap = aVCharHtmlAbsMap;
    1561           0 :             m_pHMap = aHCharHtmlAbsMap;
    1562             :         }
    1563             :         else
    1564             :         {
    1565           0 :             m_pVMap = aVCharMap;
    1566           0 :             m_pHMap = aHCharMap;
    1567             :         }
    1568             :     }
    1569           0 :     else if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1570             :     {
    1571           0 :         m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap     : aVAsCharMap;
    1572           0 :         m_pHMap = 0;
    1573           0 :         bEnable = false;
    1574             :     }
    1575           0 :     m_pHoriLB->Enable( bEnable );
    1576           0 :     m_pHoriFT->Enable( bEnable );
    1577             : 
    1578             :     // select current Pos
    1579             :     // horizontal
    1580           0 :     if ( nH == USHRT_MAX )
    1581             :     {
    1582           0 :         nH    = m_nOldH;
    1583           0 :         nHRel = m_nOldHRel;
    1584             :     }
    1585             :     // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB>
    1586           0 :     sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_pHoriLB);
    1587           0 :     FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_pHoriToLB, *m_pHoriToFT);
    1588             : 
    1589             :     // vertical
    1590           0 :     if ( nV == USHRT_MAX )
    1591             :     {
    1592           0 :         nV    = m_nOldV;
    1593           0 :         nVRel = m_nOldVRel;
    1594             :     }
    1595             :     // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB>
    1596           0 :     nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_pVertLB);
    1597           0 :     FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_pVertToLB, *m_pVertToFT);
    1598             : 
    1599             :     // Edits init
    1600           0 :     bEnable = nH == HoriOrientation::NONE &&
    1601           0 :             nAnchor != TextContentAnchorType_AS_CHARACTER;//#61359# why not in formats&& !bFormat;
    1602           0 :     if (!bEnable)
    1603             :     {
    1604           0 :         m_pHoriByMF->SetValue( 0, FUNIT_TWIP );
    1605           0 :         if (nX != LONG_MAX && m_bHtmlMode)
    1606           0 :             m_pHoriByMF->SetModifyFlag();
    1607             :     }
    1608           0 :     else if(m_bIsMultiSelection)
    1609             :     {
    1610           0 :          m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(m_aRect.Left()), FUNIT_TWIP );
    1611             :     }
    1612             :     else
    1613             :     {
    1614           0 :         if (nX != LONG_MAX)
    1615           0 :             m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(nX), FUNIT_TWIP );
    1616             :     }
    1617           0 :     m_pHoriByFT->Enable( bEnable );
    1618           0 :     m_pHoriByMF->Enable( bEnable );
    1619             : 
    1620           0 :     bEnable = nV == VertOrientation::NONE;
    1621           0 :     if ( !bEnable )
    1622             :     {
    1623           0 :         m_pVertByMF->SetValue( 0, FUNIT_TWIP );
    1624           0 :         if(nY != LONG_MAX && m_bHtmlMode)
    1625           0 :             m_pVertByMF->SetModifyFlag();
    1626             :     }
    1627           0 :     else if(m_bIsMultiSelection)
    1628             :     {
    1629           0 :          m_pVertByMF->SetValue( m_pVertByMF->Normalize(m_aRect.Top()), FUNIT_TWIP );
    1630             :     }
    1631             :     else
    1632             :     {
    1633           0 :         if ( nAnchor == TextContentAnchorType_AS_CHARACTER )
    1634             :         {
    1635           0 :             if ( nY == LONG_MAX )
    1636           0 :                 nY = 0;
    1637             :             else
    1638           0 :                 nY *= -1;
    1639             :         }
    1640           0 :         if ( nY != LONG_MAX )
    1641           0 :             m_pVertByMF->SetValue( m_pVertByMF->Normalize(nY), FUNIT_TWIP );
    1642             :     }
    1643           0 :     m_pVertByFT->Enable( bEnable );
    1644           0 :     m_pVertByMF->Enable( bEnable );
    1645           0 :     UpdateExample();
    1646           0 : }
    1647             : 
    1648           0 : void SvxSwPosSizeTabPage::UpdateExample()
    1649             : {
    1650           0 :     sal_Int32 nPos = m_pHoriLB->GetSelectEntryPos();
    1651           0 :     if ( m_pHMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1652             :     {
    1653           0 :         sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB);
    1654           0 :         short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriLB, *m_pHoriToLB);
    1655           0 :         short nRel = GetRelation(m_pHMap, *m_pHoriToLB);
    1656             : 
    1657           0 :         m_pExampleWN->SetHAlign(nAlign);
    1658           0 :         m_pExampleWN->SetHoriRel(nRel);
    1659             :     }
    1660             : 
    1661           0 :     nPos = m_pVertLB->GetSelectEntryPos();
    1662           0 :     if ( m_pVMap && nPos != LISTBOX_ENTRY_NOTFOUND )
    1663             :     {
    1664           0 :         sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB);
    1665           0 :         sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertLB, *m_pVertToLB);
    1666           0 :         sal_uInt16 nRel = GetRelation(m_pVMap, *m_pVertToLB);
    1667             : 
    1668           0 :         m_pExampleWN->SetVAlign(nAlign);
    1669           0 :         m_pExampleWN->SetVertRel(nRel);
    1670             :     }
    1671             : 
    1672             :     // Size
    1673           0 :     long nXPos = static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP)));
    1674           0 :     long nYPos = static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP)));
    1675           0 :     m_pExampleWN->SetRelPos(Point(nXPos, nYPos));
    1676             : 
    1677           0 :     m_pExampleWN->SetAnchor( GetAnchorType() );
    1678           0 :     m_pExampleWN->Invalidate();
    1679           0 : }
    1680             : 
    1681           0 : sal_uLong SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign,
    1682             :         sal_uInt16 nRel, ListBox &rLB, FixedText &rFT)
    1683             : {
    1684           0 :     OUString sSelEntry;
    1685           0 :     sal_uLong  nLBRelations = 0;
    1686           0 :     std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
    1687             : 
    1688           0 :     rLB.Clear();
    1689             : 
    1690           0 :     if (nMapPos < nMapCount)
    1691             :     {
    1692           0 :         if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap)
    1693             :         {
    1694           0 :             OUString sOldEntry(rLB.GetSelectEntry());
    1695           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap);
    1696           0 :             SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
    1697             : 
    1698           0 :             for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++)
    1699             :             {
    1700           0 :                 if (pMap[_nMapPos].eStrId == eStrId)
    1701             :                 {
    1702           0 :                     nLBRelations = pMap[_nMapPos].nLBRelations;
    1703           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1704             :                     {
    1705           0 :                         if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation)
    1706             :                         {
    1707           0 :                             SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId;
    1708             : 
    1709           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1710           0 :                             OUString sEntry = m_aFramePosString.GetString(sStrId1);
    1711           0 :                             sal_Int32 nPos = rLB.InsertEntry(sEntry);
    1712           0 :                             rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]);
    1713           0 :                             if (pMap[_nMapPos].nAlign == nAlign)
    1714           0 :                                 sSelEntry = sEntry;
    1715           0 :                             break;
    1716             :                         }
    1717             :                     }
    1718             :                 }
    1719             :             }
    1720           0 :             if (!sSelEntry.isEmpty())
    1721           0 :                 rLB.SelectEntry(sSelEntry);
    1722             :             else
    1723             :             {
    1724           0 :                 rLB.SelectEntry(sOldEntry);
    1725             : 
    1726           0 :                 if (!rLB.GetSelectEntryCount())
    1727             :                 {
    1728           0 :                     for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
    1729             :                     {
    1730           0 :                         RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(i));
    1731           0 :                         if (pEntry->nLBRelation == LB_REL_CHAR) // Default
    1732             :                         {
    1733           0 :                             rLB.SelectEntryPos(i);
    1734           0 :                             break;
    1735             :                         }
    1736             :                     }
    1737             :                 }
    1738           0 :             }
    1739             :         }
    1740             :         else
    1741             :         {
    1742           0 :             sal_uInt16 nRelCount = SAL_N_ELEMENTS(aRelationMap);
    1743             : 
    1744             :             // #i22341# - special handling for map <aVCharMap>,
    1745             :             // because its ambigous in its <eStrId>/<eMirrorStrId>.
    1746           0 :             if ( pMap == aVCharMap )
    1747             :             {
    1748             :                 nLBRelations = ::lcl_GetLBRelationsForStrID( pMap,
    1749           0 :                                              ( m_pHoriMirrorCB->IsChecked()
    1750           0 :                                                ? pMap[nMapPos].eMirrorStrId
    1751           0 :                                                : pMap[nMapPos].eStrId ),
    1752           0 :                                              m_pHoriMirrorCB->IsChecked() );
    1753             :             }
    1754             :             else
    1755             :             {
    1756           0 :                 nLBRelations = pMap[nMapPos].nLBRelations;
    1757             :             }
    1758             : 
    1759           0 :             for (sal_uLong nBit = 1; nBit < 0x80000000; nBit <<= 1)
    1760             :             {
    1761           0 :                 if (nLBRelations & nBit)
    1762             :                 {
    1763           0 :                     for (sal_uInt16 nRelPos = 0; nRelPos < nRelCount; nRelPos++)
    1764             :                     {
    1765           0 :                         if (aRelationMap[nRelPos].nLBRelation == nBit)
    1766             :                         {
    1767           0 :                             SvxSwFramePosString::StringId sStrId1 = m_pHoriMirrorCB->IsChecked() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId;
    1768           0 :                             sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1769           0 :                             OUString sEntry = m_aFramePosString.GetString(sStrId1);
    1770           0 :                             sal_Int32 nPos = rLB.InsertEntry(sEntry);
    1771           0 :                             rLB.SetEntryData(nPos, &aRelationMap[nRelPos]);
    1772           0 :                             if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel)
    1773           0 :                                 sSelEntry = sEntry;
    1774             :                         }
    1775             :                     }
    1776             :                 }
    1777             :             }
    1778           0 :             if (!sSelEntry.isEmpty())
    1779           0 :                 rLB.SelectEntry(sSelEntry);
    1780             :             else
    1781             :             {
    1782             :                 // Probably anchor change. So look for a similar relation.
    1783           0 :                 switch (nRel)
    1784             :                 {
    1785           0 :                     case RelOrientation::FRAME:           nRel = RelOrientation::PAGE_FRAME;    break;
    1786           0 :                     case RelOrientation::PRINT_AREA:      nRel = RelOrientation::PAGE_PRINT_AREA;  break;
    1787           0 :                     case RelOrientation::PAGE_LEFT:       nRel = RelOrientation::FRAME_LEFT;    break;
    1788           0 :                     case RelOrientation::PAGE_RIGHT:      nRel = RelOrientation::FRAME_RIGHT;   break;
    1789           0 :                     case RelOrientation::FRAME_LEFT:      nRel = RelOrientation::PAGE_LEFT;     break;
    1790           0 :                     case RelOrientation::FRAME_RIGHT:     nRel = RelOrientation::PAGE_RIGHT;    break;
    1791           0 :                     case RelOrientation::PAGE_FRAME:      nRel = RelOrientation::FRAME;           break;
    1792           0 :                     case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA;         break;
    1793             : 
    1794             :                     default:
    1795           0 :                         if (rLB.GetEntryCount())
    1796             :                         {
    1797           0 :                             RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(rLB.GetEntryCount() - 1));
    1798           0 :                             nRel = pEntry->nRelation;
    1799             :                         }
    1800           0 :                         break;
    1801             :                 }
    1802             : 
    1803           0 :                 for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++)
    1804             :                 {
    1805           0 :                     RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(i));
    1806           0 :                     if (pEntry->nRelation == nRel)
    1807             :                     {
    1808           0 :                         rLB.SelectEntryPos(i);
    1809           0 :                         break;
    1810             :                     }
    1811             :                 }
    1812             : 
    1813           0 :                 if (!rLB.GetSelectEntryCount())
    1814           0 :                     rLB.SelectEntryPos(0);
    1815             :             }
    1816             :         }
    1817             :     }
    1818             : 
    1819           0 :     rLB.Enable(rLB.GetEntryCount() != 0);
    1820           0 :     rFT.Enable(rLB.GetEntryCount() != 0);
    1821             : 
    1822           0 :     RelHdl(&rLB);
    1823             : 
    1824           0 :     return nLBRelations;
    1825             : }
    1826             : 
    1827           0 : sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap *_pMap,
    1828             :                                       sal_uInt16 _nAlign,
    1829             :                                       const sal_uInt16 _nRel,
    1830             :                                       ListBox &_rLB)
    1831             : {
    1832           0 :     OUString sSelEntry, sOldEntry;
    1833           0 :     sOldEntry = _rLB.GetSelectEntry();
    1834             : 
    1835           0 :     _rLB.Clear();
    1836             : 
    1837             :     // #i22341# - determine all possible listbox relations for
    1838             :     // given relation for map <aVCharMap>
    1839             :     const sal_uLong nLBRelations = (_pMap != aVCharMap)
    1840             :                                ? 0L
    1841           0 :                                : ::lcl_GetLBRelationsForRelations( _nRel );
    1842             : 
    1843             :     // fill listbox
    1844           0 :     std::size_t nCount = ::lcl_GetFrmMapCount(_pMap);
    1845           0 :     for (std::size_t i = 0; _pMap && i < nCount; ++i)
    1846             :     {
    1847             : //      #61359# why not from the left/from inside or from the top?
    1848             : //      if (!bFormat || (pMap[i].eStrId != SwFPos::FROMLEFT && pMap[i].eStrId != SwFPos::FROMTOP))
    1849             :         {
    1850           0 :             SvxSwFramePosString::StringId eStrId = m_pHoriMirrorCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId;
    1851           0 :             eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft);
    1852           0 :             OUString sEntry(m_aFramePosString.GetString(eStrId));
    1853           0 :             if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND)
    1854             :             {
    1855             :                 // don't insert duplicate entries at character wrapped borders
    1856           0 :                 _rLB.InsertEntry(sEntry);
    1857             :             }
    1858             :             // #i22341# - add condition to handle map <aVCharMap>
    1859             :             // that is ambigous in the alignment.
    1860           0 :             if ( _pMap[i].nAlign == _nAlign &&
    1861           0 :                  ( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
    1862             :             {
    1863           0 :                 sSelEntry = sEntry;
    1864           0 :             }
    1865             :         }
    1866             :     }
    1867             : 
    1868           0 :     _rLB.SelectEntry(sSelEntry);
    1869           0 :     if (!_rLB.GetSelectEntryCount())
    1870           0 :         _rLB.SelectEntry(sOldEntry);
    1871             : 
    1872           0 :     if (!_rLB.GetSelectEntryCount())
    1873           0 :         _rLB.SelectEntryPos(0);
    1874             : 
    1875           0 :     PosHdl(&_rLB);
    1876             : 
    1877           0 :     return GetMapPos(_pMap, _rLB);
    1878             : }
    1879             : 
    1880           0 : void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView )
    1881             : {
    1882           0 :     m_pSdrView = pSdrView;
    1883           0 :     if(!m_pSdrView)
    1884             :     {
    1885             :         OSL_FAIL("No SdrView* set");
    1886           0 :         return;
    1887             :     }
    1888             : 
    1889             :     // setting of the rectangle and the working area
    1890           0 :     m_aRect = m_pSdrView->GetAllMarkedRect();
    1891           0 :     m_pSdrView->GetSdrPageView()->LogicToPagePos( m_aRect );
    1892             : 
    1893             :     // get WorkArea
    1894           0 :     m_aWorkArea = m_pSdrView->GetWorkArea();
    1895             : 
    1896             :     // consider anchor position (for Writer)
    1897           0 :     const SdrMarkList& rMarkList = m_pSdrView->GetMarkedObjectList();
    1898           0 :     if( rMarkList.GetMarkCount() > 0 )
    1899             :     {
    1900           0 :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1901           0 :         m_aAnchorPos = pObj->GetAnchorPos();
    1902             : 
    1903           0 :         if( m_aAnchorPos != Point(0,0) ) // -> Writer
    1904             :         {
    1905           0 :             for( size_t i = 1; i < rMarkList.GetMarkCount(); ++i )
    1906             :             {
    1907           0 :                 pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
    1908           0 :                 if( m_aAnchorPos != pObj->GetAnchorPos() )
    1909             :                 {
    1910             :                     // different anchor positions -> disable positioning
    1911           0 :                     m_pPosFrame->Enable(false);
    1912           0 :                     m_bPositioningDisabled = true;
    1913           0 :                     return;
    1914             :                 }
    1915             :             }
    1916             :         }
    1917           0 :         Point aPt = m_aAnchorPos * -1;
    1918           0 :         Point aPt2 = aPt;
    1919             : 
    1920           0 :         aPt += m_aWorkArea.TopLeft();
    1921           0 :         m_aWorkArea.SetPos( aPt );
    1922             : 
    1923           0 :         aPt2 += m_aRect.TopLeft();
    1924           0 :         m_aRect.SetPos( aPt2 );
    1925             :     }
    1926             : 
    1927             :     // this should happen via SID_ATTR_TRANSFORM_AUTOSIZE
    1928           0 :     if( rMarkList.GetMarkCount() != 1 )
    1929           0 :         m_bIsMultiSelection = true;
    1930             : #if OSL_DEBUG_LEVEL > 1
    1931             :     else
    1932             :     {
    1933             :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
    1934             :         SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
    1935             :         if( ( pObj->GetObjInventor() == SdrInventor ) &&
    1936             :             ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) &&
    1937             :             pObj->HasText() )
    1938             :         {
    1939             :             OSL_FAIL("AutoWidth/AutoHeight should be enabled");
    1940             :         }
    1941             :     }
    1942             : #endif
    1943           0 : }
    1944             : 
    1945             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11