LibreOffice Module sw (master)  1
sdrhhcwrap.cxx
Go to the documentation of this file.
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 <svx/svdotext.hxx>
21 #include <svx/svdpagv.hxx>
22 #include <sfx2/printer.hxx>
23 #include <svx/svdview.hxx>
24 #include <osl/diagnose.h>
25 #include <drawdoc.hxx>
26 #include "sdrhhcwrap.hxx"
27 #include <docsh.hxx>
28 #include <wrtsh.hxx>
29 #include <view.hxx>
30 #include <dcontact.hxx>
31 #include <doc.hxx>
34 #include <edtwin.hxx>
35 
36 using namespace ::com::sun::star;
37 
39  LanguageType nSourceLanguage, LanguageType nTargetLanguage,
40  const vcl::Font* pTargetFnt,
41  sal_Int32 nConvOptions,
42  bool bInteractive ) :
43  SdrOutliner(pVw->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->
44  GetDrawOutliner().GetEmptyItemSet().GetPool(),
46  pView( pVw ),
47  pTextObj( nullptr ),
48  nOptions( nConvOptions ),
49  nDocIndex( 0 ),
50  nSourceLang( nSourceLanguage ),
51  nTargetLang( nTargetLanguage ),
52  pTargetFont( pTargetFnt ),
53  bIsInteractive( bInteractive )
54 {
55  SetRefDevice( pView->GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) );
56 
57  MapMode aMapMode (MapUnit::MapTwip);
58  SetRefMapMode(aMapMode);
59 
60  Size aSize( 1, 1 );
61  SetPaperSize( aSize );
62 
63  pOutlView.reset( new OutlinerView( this, &(pView->GetEditWin()) ) );
64  pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess().getPrinter( false ));
65 
66  // Hack: all SdrTextObj attributes should be transferred to EditEngine
67  pOutlView->SetBackgroundColor( COL_WHITE );
68 
69  InsertView( pOutlView.get() );
70  Point aPoint( 0, 0 );
71  tools::Rectangle aRect( aPoint, aSize );
72  pOutlView->SetOutputArea( aRect );
73 // SetText( NULL );
74  ClearModifyFlag();
75 }
76 
78 {
79  if (pTextObj)
80  {
81  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
82  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
83  pSdrView->SdrEndTextEdit( true );
84  SetUpdateMode(false);
85  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
86  }
87  RemoveView( pOutlView.get() );
88  pOutlView.reset();
89 }
90 
92 {
94 }
95 
97 {
98  bool bNextDoc = false;
99 
100  if ( pTextObj )
101  {
102  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
103  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
104  pSdrView->SdrEndTextEdit( true );
105  SetUpdateMode(false);
106  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
107  SetPaperSize( Size(1, 1) );
108  Clear();
109  pTextObj = nullptr;
110  }
111 
112  const auto n = nDocIndex;
113 
114  std::list<SdrTextObj*> aTextObjs;
116  for (auto const& textObj : aTextObjs)
117  {
118  pTextObj = textObj;
119  if (textObj)
120  {
121  OutlinerParaObject* pParaObj = textObj->GetOutlinerParaObject();
122  if ( pParaObj )
123  {
124  SetPaperSize( textObj->GetLogicRect().GetSize() );
125  SetText( *pParaObj );
126 
127  ClearModifyFlag();
128 
134  SetUpdateMode(true);
135  if (HasConvertibleTextPortion( nSourceLang ))
136  {
137  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
138  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
139  SdrPageView* pPV = pSdrView->GetSdrPageView();
140  nDocIndex = n;
141  bNextDoc = true;
142  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1,1)));
144  SetUpdateMode(true);
146 
147  pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), false, this, pOutlView.get(), true, true);
148  }
149  else
150  SetUpdateMode(false);
151  }
152 
153  if ( !bNextDoc )
154  pTextObj = nullptr;
155  else
156  break;
157  }
158  }
159 
160  ClearModifyFlag();
161 
162  return bNextDoc;
163 }
164 
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutlinerMode
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
SdrView * GetDrawView()
Definition: vnew.cxx:376
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
sal_Int64 n
SwEditWin & GetEditWin()
Definition: view.hxx:416
static void GetTextObjectsFromFormat(std::list< SdrTextObj * > &, SwDoc &)
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:752
const vcl::Font * pTargetFont
Definition: sdrhhcwrap.hxx:38
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
std::unique_ptr< OutlinerView > pOutlView
Definition: sdrhhcwrap.hxx:33
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:570
LanguageType nSourceLang
Definition: sdrhhcwrap.hxx:36
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2663
LanguageType nTargetLang
Definition: sdrhhcwrap.hxx:37
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
sal_uInt16 nDocIndex
Definition: sdrhhcwrap.hxx:35
SdrHHCWrapper(SwView *pVw, LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFnt, sal_Int32 nConvOptions, bool bInteractive)
Definition: sdrhhcwrap.cxx:38
SwDocShell * GetDocShell()
Definition: view.cxx:1126
bool bIsInteractive
Definition: sdrhhcwrap.hxx:39
void StartTextConversion()
Definition: sdrhhcwrap.cxx:91
SwView * pView
Definition: sdrhhcwrap.hxx:31
constexpr Size GetSize() const
weld::Window * GetFrameWeld() const
SdrTextObj * pTextObj
Definition: sdrhhcwrap.hxx:32
sal_Int32 nOptions
Definition: sdrhhcwrap.hxx:34
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
SdrPageView * GetSdrPageView() const
virtual ~SdrHHCWrapper() override
Definition: sdrhhcwrap.cxx:77
virtual bool ConvertNextDocument() override
Definition: sdrhhcwrap.cxx:96
Definition: view.hxx:144
virtual const tools::Rectangle & GetLogicRect() const override